Refreshing the UI in WPF
If you are using WPF and missing the 'Application.DoEvents();' method, you know from Windows Forms to refresh the UI, here is a solution for you. I had the same problem and was looking for a way to refresh the UI in runtime.
After some looking around I found a solution that worked for me. There is just one problem: you need some more code than before. So I made a function for this and copy it into each WPF-project. This way I just need to call 'DoEvents();'. Hope it will work for you, too.
After some looking around I found a solution that worked for me. There is just one problem: you need some more code than before. So I made a function for this and copy it into each WPF-project. This way I just need to call 'DoEvents();'. Hope it will work for you, too.
1 2 3 4 5 6 7 8 9 10 11 12 | private object ExitFrame(object f) { ((DispatcherFrame)f).Continue = false; return null; } private void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); } |
Comments
Post a Comment