CommandManager.InvalidateRequerySuggested Método

Definición

Obliga a CommandManager a provocar el evento RequerySuggested.

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

Ejemplos

En el ejemplo siguiente se usa un DispatcherTimer objeto para llamar InvalidateRequerySuggested periódicamente a para forzar que CommandManager genere el RequerySuggested evento.

//  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

Comentarios

El CommandManager único que presta atención a ciertas condiciones para determinar cuándo ha cambiado el destino del comando, como el cambio en el foco del teclado. En situaciones en CommandManager las que no determina suficientemente un cambio en las condiciones que hacen que un comando no pueda ejecutarse, InvalidateRequerySuggested se puede llamar a para forzar que CommandManager genere el RequerySuggested evento.

Se aplica a