CommandManager.InvalidateRequerySuggested Metodo

Definizione

Forza l'oggetto CommandManager a generare l'evento RequerySuggested .

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

Esempio

Nell'esempio seguente viene utilizzato un DispatcherTimer oggetto per chiamare InvalidateRequerySuggested periodicamente per forzare l'oggetto CommandManager per generare l'evento 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

Commenti

L'unica CommandManager attenzione a determinate condizioni per determinare quando la destinazione del comando è cambiata, ad esempio la modifica dello stato attivo della tastiera. Nelle situazioni in cui non CommandManager determina sufficientemente una modifica delle condizioni che causano l'esecuzione di un comando, InvalidateRequerySuggested è possibile chiamare per forzare l'oggetto CommandManager a generare l'evento RequerySuggested .

Si applica a