tags:

views:

307

answers:

2

I have several wpf pages with update/delete/add buttons. I want to display to the user messages like "successful delete", etc. How can I best implement this so the message is defined in a single place (similar to an asp.net master page) and I can update this message from anywhere?

+2  A: 

You may want to consider doing a publish/subscribe ("Observer" pattern) -- define a "status changed" event on a base page, and create a custom control that sets up a delegate and event handler to listen for status updates.

Then you could drop the custom control on any page that inherits from the base, and it would automatically listen for and display status messages whenever the event is fired.

Edit: I put together a sample implementation of this pattern and published a blog post walking through the code.

Guy Starbuck
+1  A: 

I don't think you have the ASP.Net master pages translated to the WPF Page world just yet.
A workaround till MS gets there, I would probably put a Control at the top of the page (or wherever) that just displays a particular User-level "Application Setting". You can update the string property like

MyAppUserSettings.StatusMessage = "You just deleted the administrator!"

Crude but will get the job done I think!

Gishu