Share via


CommandManager.InvalidateRequerySuggested Yöntem

Tanım

öğesini CommandManager olayı tetiklemeye zorlar RequerySuggested .

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

Örnekler

Aşağıdaki örnekte, olayı tetiklemeye zorlamak CommandManager için öğesini düzenli aralıklarla çağırmak RequerySuggestedInvalidateRequerySuggested için bir DispatcherTimer kullanılır.

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

Açıklamalar

Yalnızca CommandManager komut hedefinin ne zaman değiştiğini belirlerken klavye odağındaki değişiklik gibi belirli koşullara dikkat eder. bir komutun CommandManager yürütülemediği koşullardaki bir değişikliği yeterince belirlemediği durumlarda, InvalidateRequerySuggested olayı tetiklemeye RequerySuggested zorlamak CommandManager için çağrılabilir.

Şunlara uygulanır