简体   繁体   中英

WPF overlay example, binding not work correctly

I tried today this example => http://weblogs.asp.net/psteele/archive/2011/05/31/wpf-simple-busy-overlay.aspx for simple overlay in my window to show the user im proceeding his action. But I have a little problem. In my function to proceed the action I switch the IsBusy property at the beginning to true and at the end to false . But the gui does not update and i don't see the overlay. I tried an extra button to switch the overlay and it works.

Do someone know why I have this problem? I think it has something to do with the priority of binding operations, but I don't know it exactly.

Without seeing any of your own code...

Is it possible that the operation to switch the IsBusy property is happening on the UI/Main thread? So, the UI actually doesn't get a chance to 'refresh' itself between you setting the property true and then back to false?

If you only set IsBusy = true but not back to false, is the overlay shown? If yes, then this is probably what's happening; you need to invoke the method on a different thread so the UI can update.

Your IsBusy property needs to be either a dependency property or implement the INotifyPropertyChanged interface to make the UI recognize its changes. Otherwise the UI will not know that you set the property and as such won't show the overlay.

For unknown reasons this is not done in the example source of your example so it shouldn't work there either. In short, you basically want to raise the PropertyChanged event after setting the IsBusy property.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM