Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetroWindow OnClosing exception (.Net 4.0) #2476

Closed
gigios opened this issue Apr 19, 2016 · 2 comments
Closed

MetroWindow OnClosing exception (.Net 4.0) #2476

gigios opened this issue Apr 19, 2016 · 2 comments
Labels
Milestone

Comments

@gigios
Copy link

gigios commented Apr 19, 2016

It is not clear why but, when I close the main window of my application, I receive an exception because the variable metroActiveDialogContainer is null.
I have checked my code and for each MetroWindow loaded I have the same OnClosing event, but when it is closed the last window I receive an additional OnClosing event where the metroActiveDialogContainer is null.

I have applied this fix (MetroWindow.cs line 782):

var dialog = this.Invoke(() => this.metroActiveDialogContainer?.Children.OfType<BaseMetroDialog>().LastOrDefault());

I have only added a Null-conditional operator (“?.”)

Probably the problem is on my side (I think that there is an hidden window that is loaded and not closed in my code) but I think that this fix can be inserted in the 'official' code.

@punker76 punker76 added this to the 1.3.0 milestone Apr 19, 2016
punker76 added a commit that referenced this issue Apr 19, 2016
the metroActiveDialogContainer can be null if the window is not loaded
@punker76
Copy link
Member

punker76 commented Apr 19, 2016

@gigios I've added this check in a96b15d. This could happen if the window is not loaded, so the metroActiveDialogContainer is null at the closing event .

@gigios
Copy link
Author

gigios commented Apr 19, 2016

Very fast :)
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants