CommandManager.InvalidateRequerySuggested Method

Forces the CommandManager to raise the RequerySuggested event.

Namespace:  System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

'Declaration
Public Shared Sub InvalidateRequerySuggested

The CommandManager only pays attention to certain conditions in determining when the command target has changed, such as change in keyboard focus. In situations where the CommandManager does not sufficiently determine a change in conditions that cause a command to not be able to execute, InvalidateRequerySuggested can be called to force the CommandManager to raise the RequerySuggested event.

The following example uses a DispatcherTimer to periodically call InvalidateRequerySuggested to force the CommandManager to raise the RequerySuggested event.

		'  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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft