CommandManager.InvalidateRequerySuggested Método

Definición

CommandManager Obliga a que genere el RequerySuggested evento.

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 para llamar InvalidateRequerySuggested periódicamente a para forzar CommandManager al objeto para generar 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 CommandManager en 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 al CommandManager que genere el RequerySuggested evento.

Se aplica a