This is a mirror of official site: http://jasper-net.blogspot.com/

InvalidateRequerySuggested on GUI Thread

| Tuesday, March 8, 2011
I've been having issues where buttons weren't getting enabled on my WPF application, only by clicking the form would they work.

I found that I need to force the refresh using CommandManager.InvalidateRequerySuggested but that didn't work, the reason being I wasn't on the GUI Thread, I was on another thread, so here is my little helper class to do it.

public static void RaiseInvalidateRequerySuggested()
{
     Dispatcher dispatcher = null;
 
     if (Application.Current != null)
      {
         dispatcher = Application.Current.Dispatcher;
       }
 
      if (dispatcher != null && !dispatcher.CheckAccess())
       {
        dispatcher.BeginInvoke(DispatcherPriority.Normal,(Action)CommandManager.InvalidateRequerySuggested);
        }
}

Read more: Sarkie's Site

Posted via email from Jasper-net

0 comments: