CommandManager.InvalidateRequerySuggested Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Kényszeríti az CommandManager eseményt RequerySuggested .
public:
static void InvalidateRequerySuggested();
public static void InvalidateRequerySuggested();
static member InvalidateRequerySuggested : unit -> unit
Public Shared Sub InvalidateRequerySuggested ()
Példák
Az alábbi példa egy DispatcherTimer rendszeres hívással InvalidateRequerySuggested kényszeríti az CommandManager esemény indítását 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
Megjegyzések
Csak CommandManager a parancscél módosításának bizonyos feltételeire figyel, például a billentyűzetfókusz módosítására. Azokban az esetekben, amikor a CommandManager parancs nem határoz meg kellőképpen olyan változást a feltételekben, amelyek miatt egy parancs nem hajtható végre, meghívható, InvalidateRequerySuggested hogy kényszerítse az CommandManagerRequerySuggested eseményt.