I try to get the following done:
A WPF application where i have multiple buttons where you can set a notification message. Depending on the button, you can set different messages.
What i did, was on the message button i have put this code:
private void button1_Click(object sender, RoutedEventArgs e)
{
CounterMessage msgOne = new CounterMessage();
msgOne.ShowDialog();
}
This will open op a new WPF window here only is a textbox and an exit button. On exit in this message window, it will save the message to a parameter.
But here is the trick. I want to use this message window for multiple notifications, and it will display in the textbox any text content if there is already any on a string in the application.
So for example: In the main app i have button A and B to set the notification on. I click on button A, the showdialog pops up and in the textbox already have "you clicked button A" If it was button B that has been clicked, it should display "you clicked button B"
So i should sent some extra info with the ShowDialog, so i can use the messagewindow for each one. Could someone help me out a bit herE?
I must say i find it a bit hard do decently discribe what i want, so i hope i made myself clear enough.
EDIT So hat i want is showing the content of a string parameter (to be exact: Properties.Settings.Default.XXX) into the textbox that is in the Countermessage window
I am not entirely sure what you are asking, but it sounds like you want something like this. I am assuming that CounterMessage is a Window, and that there is some binding mechanism or property that displays what the message is.
public class CounterMessage : Window
{
public CounterMessage(string message)
{
this.Message = message;
}
public string Message
{
get;
set;
}
}
Your button event would then be something along the lines of:
private void button1_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
CounterMessage msgOne = new CounterMessage(btn.Text);
msgOne.ShowDialog();
}
The point being that you don't send something to the ShowDialog method, but rather to the class that is the dialog itself. I also assume that the dialog does more than just displaying the message - otherwise, you would just use MessageBox.Show(....)