Reputation: 7298
I am making an application where I need to use message box. I am trying to make my own custom message box in WPF. I am newbie to WPF. I have searched for it on google but not able to find proper solution. I find a way for it but not sure it will work or not.
I have added a another form which I want to use it as message box. In the main form, I have written:
MyMessageBox Box;
public MainWindow()
{
InitializeComponent();
Box = new MyMessageBox();
}
private void button_Click(object sender, RoutedEventArgs e)
{
Box.Show();
}
I have button in main window.So whenever I click on that button, message box window appears. I want to know that
1.is this the correct way of doing it.?
2.What additional code I have to add two made buttons of YES NO CANCEL according to requirement like in original windows messagebox
3.Please guide me to the tutorials where this process has already been covered.
Thanks
Upvotes: 0
Views: 3225
Reputation: 26
This is your simplest solution
MessageBox.Show("This is your messagebox with AbortRetryIgnore Buttons", "Your title", MessageBoxButtons.AbortRetryIgnore);
MessageBox.Show("This is your messagebox with OK Button", "Your title", MessageBoxButtons.OK);
MessageBox.Show("This is your messagebox with OK Cancel Buttons", "Your title", MessageBoxButtons.OKCancel);
MessageBox.Show("This is your messagebox with Retry Cancel Buttons", "Your title", MessageBoxButtons.RetryCancel);
MessageBox.Show("This is your messagebox with Yes No Buttons", "Your title", MessageBoxButtons.YesNo);
MessageBox.Show("This is your messagebox with Yes No Cancel Buttons", "Your title", MessageBoxButtons.YesNoCancel);
Upvotes: 0
Reputation: 398
based on your example: You have to defiened your own window MyMessageBox
of Window
.
What you are looking for is MessageBox.Show()
with all overloads.
Upvotes: 1