CommandManager.InvalidateRequerySuggested Método

Definição

Obriga-os CommandManager a levantar o RequerySuggested evento.

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

Exemplos

O exemplo seguinte usa um DispatcherTimer para InvalidateRequerySuggested chamar periodicamente para forçar o CommandManager a levantar o 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

Observações

CommandManager presta atenção a certas condições para determinar quando o alvo do comando mudou, como a alteração no foco do teclado. Em situações em que o CommandManager não determina suficientemente uma alteração nas condições que faça com que um comando não seja executado, InvalidateRequerySuggested pode ser chamado para forçar o CommandManager a levantar o RequerySuggested evento.

Aplica-se a