Repro:
1) Create a ChildWindow
2) Add a handler for Closed (ClosedHandler) that calls Close again on the ChildWindow
Expected: the 2nd close would error out or be a no-opt
Actual: since _isOpen = false is set *after* the closed event is raised, the logic decrementing OpenChildWindowCount is called twice, resulting in a negative count.
Result: the RootVisual stays disabled, which really sucks.
Suggestion: set _isOpen to false before raising the Closed event.
Comments: ** Comment from web user: rtenhoor **
1) Create a ChildWindow
2) Add a handler for Closed (ClosedHandler) that calls Close again on the ChildWindow
Expected: the 2nd close would error out or be a no-opt
Actual: since _isOpen = false is set *after* the closed event is raised, the logic decrementing OpenChildWindowCount is called twice, resulting in a negative count.
Result: the RootVisual stays disabled, which really sucks.
Suggestion: set _isOpen to false before raising the Closed event.
Comments: ** Comment from web user: rtenhoor **
Our users complained about this intermittently happening and it took some time reproducing. We did find the practical circumstances under which this happens: when a user clicks on our ChildWindow close button twice (i.e. a double-click). The closed event will fire twice and the subsequent opening/closing of any ChildWindow will permanently disable the application (counter becomes negative).
A work-around for us is to disable the close button of the ChildWindow during closing:
private void closeButton_Click(object sender, RoutedEventArgs e)
{
closeButton.IsEnabled = false;
Close();
.... the rest of the event handler...
}