I have a WPF program with a callback that executes after an async method.
The callback looks like this:
public void ProcessCompleteCallback()
{
MessageBox.Show("Process completed.");
GenerateOutputButton.IsEnabled = true;
LoadingGifImage.Visibility = Visibility.Hidden;
CommandManager.InvalidateRequerySuggested();
}
The first line get executed, but there's no change in the GUI regarding the second and third lines. I tried to force a Requery by invoking the CommandManager, but it does not help.
Any idea why it isn't working?
Try this:
public void ProcessCompleteCallback()
{
MessageBox.Show("Process completed.");
Application.Current.Dispatcher.Invoke(() =>
{
GenerateOutputButton.IsEnabled = true;
LoadingGifImage.Visibility = Visibility.Hidden;
CommandManager.InvalidateRequerySuggested();
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.