CommandManager.InvalidateRequerySuggested 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
强制 CommandManager 引发 RequerySuggested 事件。
public:
 static void InvalidateRequerySuggested();public static void InvalidateRequerySuggested();static member InvalidateRequerySuggested : unit -> unitPublic Shared Sub InvalidateRequerySuggested ()示例
以下示例使用 DispatcherTimer 定期调用 InvalidateRequerySuggested 来强制 CommandManager 引发 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
注解
仅在 CommandManager 确定命令目标更改时注意某些条件,例如键盘焦点的更改。 CommandManager如果 无法充分确定导致命令无法执行的条件更改,InvalidateRequerySuggested则可以调用 以强制 CommandManager 引发RequerySuggested事件。