user3735822
user3735822

Reputation: 335

How to make custom MessageBox in silverlight

I am silverlight beginner and i am in a situation that i have to pop up a message box containing three buttons (Yes/No/Ok). Please do not give me the following suggestion(I already tried and tired) :

(1) Use Childwindow : Though it is a good solution but the way it pop ups is not like MessageBox pop up because in message box pop up we can see clearly the data behind but we cannot edit/click/change it whereas in child window pop up it is less visible. (So if you know any way to make childwindow back ground visible just like MessageBox then you are most welcome to tell me alternatives).

(2) Use PopUp control : Because it do not pop up exactly and can be distuinguished easily from MessageBox and the data behind is always editable when PopUp control is pop-Uped and if i set it to Collapsed then it show nothing. So i want pop up exactly like MessageBox.Show() Pop Ups.

Whereas in MeassageBox.Show() we can see that when it is pop uped the GUi behind is visible but not clickable and the way it Pop ups is perfect so i want something that could Pop up exactly the same way with three buttons on it.

Could some one please help me in achieving my target ?

Upvotes: 3

Views: 788

Answers (1)

McGarnagle
McGarnagle

Reputation: 102723

If I understand the question, you want a popup in the default MessageBox style, only with Yes/No/OK buttons. Recognize that there is not an ideal solution -- even the Windows API (which you don't have access to in Silverlight outside of full trust) doesn't provide this combination of buttons (without using advanced techniques anyway).

So, you are left with the non-ideal options of making use of Popup or ChildWindow. I think it would be misguided to try and mimic the exact style of the Windows dialog popup, since that style depends on the system, which you don't have access to from Silverlight. Instead, I recommend just choosing a style that you are comfortable with, and which matches the theme of your application.

In any case, as with all controls, you have two options for styling ChildWindow:

1) Modify its style properties like OverlayOpacity, BorderBrush, etc. Take a look at the default control template to see how those properties are used in the control's presentation.

2) If you need to do more customization than the default template allows, then you can always copy-and-modify the ControlTemplate. That allows you fine-grained control over everything about the popup's appearance, including its open/close animations. There's lots of info on the web about modifying control templates (eg, MSDN).

Upvotes: 1

Related Questions