I've blogged about implementing a busy indicator before, this post is an extension of this pattern to implement a message box - this is instead of using the namespace provide by the .Net framework.
The UI is shown below, and when the button is clicked in the middle content it will display the message as an overlay - as you can see I've coloured it green to get your attention:
As with the previous post, the XAML for the View hasn't changed it's still very simple:
What's changed is the style applied to the ViewHost class, as you can see there's now a MessageOverlay as well as a BusyOverlay. You'll notice the z-order of the MessageOverlay is one less the BusyOverlay, this is to make sure the busy indicator is always displayed at the highest order and hence would be an overlay on top of the message overlay:
The message overlay is trigger by the binding MessageMonitor, this is an implementation of the following interface, the one I'm using is shown below along with interface:
What you see is the message is exposed as a view model implementing the IMessageViewModel interface, the implementation I'm using is shown below as you can see I'm injecting in the actual message and the busy indicator, I use these to simulate an action when the 'Show Busy & Close' button is clicked. The UI is shown below, and when the button is clicked in the middle content it will display the message as an overlay - as you can see I've coloured it green to get your attention:
As with the previous post, the XAML for the View hasn't changed it's still very simple:
What's changed is the style applied to the ViewHost class, as you can see there's now a MessageOverlay as well as a BusyOverlay. You'll notice the z-order of the MessageOverlay is one less the BusyOverlay, this is to make sure the busy indicator is always displayed at the highest order and hence would be an overlay on top of the message overlay:
Loading ....
Loading ....
The code is available for download from github.
Comments
Post a Comment