CommandManager.InvalidateRequerySuggested 메서드

정의

CommandManager 이벤트를 발생 RequerySuggested 하도록 합니다.

public:
 static void InvalidateRequerySuggested();
public static void InvalidateRequerySuggested();
static member InvalidateRequerySuggested : unit -> unit
Public Shared Sub InvalidateRequerySuggested ()

예제

다음 예제에서는 주기적으로 호출 DispatcherTimer 을 사용하여 InvalidateRequerySuggested 이벤트를 발생 CommandManager 하도록 강제 RequerySuggested 합니다.

//  System.Windows.Threading.DispatcherTimer.Tick handler
//
//  Updates the current seconds display and calls
//  InvalidateRequerySuggested on the CommandManager to force 
//  the Command to raise the CanExecuteChanged event.
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
    // Updating the Label which displays the current second
    lblSeconds.Content = DateTime.Now.Second;

    // Forcing the CommandManager to raise the RequerySuggested event
    CommandManager.InvalidateRequerySuggested();
}
'  System.Windows.Threading.DispatcherTimer.Tick handler
'
'  Updates the current seconds display and calls
'  InvalidateRequerySuggested on the CommandManager to force 
'  the Command to raise the CanExecuteChanged event.
Private Sub dispatcherTimer_Tick(ByVal sender As Object, ByVal e As EventArgs)
    ' Updating the Label which displays the current second
    lblSeconds.Content = Date.Now.Second

    ' Forcing the CommandManager to raise the RequerySuggested event
    CommandManager.InvalidateRequerySuggested()
End Sub

설명

CommandManager 키보드 포커스의 변경과 같이 명령 대상이 변경된 시기를 결정하는 특정 조건에만 주의합니다. 명령이 CommandManager 실행 InvalidateRequerySuggested 되지 않는 조건의 변경을 충분히 결정하지 못하는 경우에는 강제로 이벤트를 발생 CommandManager 하도록 RequerySuggested 호출할 수 있습니다.

적용 대상