Skip to content

Commit

Permalink
Merge pull request #44 from scdmitryvodich/LayoutFloatingWindowContro…
Browse files Browse the repository at this point in the history
…lVisibilityProblem

Fix Visibility issue on closing LayoutFloatingWindowControl
  • Loading branch information
Dirkster99 authored Jun 20, 2019
2 parents 1f9bf56 + b7bb120 commit d865ec2
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This program is provided to you under the terms of the Microsoft Public
***********************************************************************************/

using System;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -58,6 +59,7 @@ protected LayoutFloatingWindowControl( ILayoutElement model )
{
this.Loaded += new RoutedEventHandler( OnLoaded );
this.Unloaded += new RoutedEventHandler( OnUnloaded );
Closing += OnClosing;
_model = model;
}

Expand Down Expand Up @@ -453,6 +455,19 @@ private void OnUnloaded( object sender, RoutedEventArgs e )
}
}

private void OnClosing(object sender, CancelEventArgs e)
{
Closing -= OnClosing;

// If this window was Closed not from InternalClose method,
// mark it as closing to avoid "InvalidOperationException: : Cannot set Visibility to Visible or call Show, ShowDialog,
// Close, or WindowInteropHelper.EnsureHandle while a Window is closing".
if (!_isClosing)
{
_isClosing = true;
}
}

private void OnActivated( object sender, EventArgs e )
{
this.Activated -= new EventHandler( OnActivated );
Expand Down

0 comments on commit d865ec2

Please sign in to comment.