This question is locked. New answers and comments are not allowed.
I have implemented a UserControl which works like System,Windows.MessageBox using RadWindow.
The control allows to use Buttons inside of it.
I want to implement the method Show just like System,Windows.MessageBox, returning pressed button.
So I have a var in control named buttonpressed, which is setted once some button was clicked.
Manager event, buttonClick:
private void buttonClick(object sender, RoutedEventArgs e) |
{ |
Button b = (Button)sender; |
MsgBoxButton botonType = (MsgBoxButton)b.Content; |
this.window_Win.Hide(); |
this.buttonPressed = botonType; |
} |
And in the method Show I have the next code:
public static MsgBoxButton Show(MessageBoxType type, string header, string message, string detail,MsgBoxButtonCollection buttons) |
{ |
MsgBox box = new MsgBox(); |
box.Type = type; |
box.Header = header; |
box.Message = message; |
box.Detail = detail; |
box.CreateButtons(buttons,null,null); |
/*box.Show() only calls RadWindow.Show()*/ |
box.Show(); |
while (box.buttonPressed == null) |
{ |
} |
return box.buttonPressed; |
} |
the problem is that the window is not showned when I call box.Show(). The code below is executed, and it ends with an infinite loop.
I suppose it is a problem with threads. Can you help me?