I have multiple instances of the same User Control inside a stack panel, with a button in each user control.
When I click this button I want it to open a new window and then disable the stack panel containing all the user controls, such that multiple instance of this window can not be opened at the same time. I then want to be able to re-enable the stack panel upon the user closing the newly opened window.
Currently I have this code, when my button is inside of the Main Window XAML and not a part of the User Control:
private void ButtonClick(object sender, RoutedEventArgs e)
{
RouteViewer Rv = new RouteViewer((sender as Button).Tag).ToString());
Rv.Owner = this;
Rv.Show();
StackPanel.IsEnabled = false; //Disables the stackpanel
Rv.Closed += new EventHandler(RvClosed);
}
void RvClosed(object sender, EventArgs e)
{
StackPanel.IsEnabled = true; //Re-enables the stackpanel
}
As you can see the issue is due to the Stack Panel not being apart of the User Control. I've been googling and suspect the answer is something to do with routed events, any help would be appreciated.