Hi Guys!
I’m having a similar problem with the WindowContainer/ChildWindow.
Here is a little sample snipped:
So after I start the application, the following happens:
I’m having a similar problem with the WindowContainer/ChildWindow.
Here is a little sample snipped:
<Grid>
<Grid>
<TextBlock Text="MainContent" />
</Grid>
<xctk:WindowContainer ModalBackgroundBrush="LightGray">
<xctk:ChildWindow Width="480"
Height="320"
IsModal="True"
Visibility="Collapsed"
WindowState="Closed">
<TextBlock Text="Test" />
</xctk:ChildWindow>
</xctk:WindowContainer>
</Grid>
When starting the application, the WindowContainer is in “modal”-mode and therefore blocks the content of my MainContent grid. This happens although there is no window visible. My only window has a WindowState of Closed and the Visibility is set to Collapsed as well.So after I start the application, the following happens:
- WindowContainer is created
- ChildWindow is created (Visibility=Visible, IsVisible=false)
- WindowContainer. OnVisualChildrenChanged is called and events are hooked up
- ChildWindow.IsModel is set to true, which triggers the IsModalChanged in the WindowContainer class. This in turn calls WindowContainer. SetModalBackground method. At this time we have a ChildWindow that is Visible (Visibility, but not IsVisible)!
-
ChildWindow.Visibility is set to Collapsed. Although the Visibility of the ChildWindow has changed, the IsVisibleChanged event is not triggered, because IsVisible was never true.
public class CustomChildWindow : ChildWindow
{
static CustomChildWindow()
{
ChildWindow.WindowStateProperty.OverrideMetadata(typeof(CustomChildWindow), new FrameworkPropertyMetadata(Xceed.Wpf.Toolkit.WindowState.Closed, null, OnWindowStateChanged));
}
public CustomChildWindow()
{
Visibility = System.Windows.Visibility.Collapsed;
}
private static object OnWindowStateChanged(DependencyObject d, object baseValue)
{
var window = d as CustomChildWindow;
if (window != null && baseValue != null)
{
window.Visibility = (Xceed.Wpf.Toolkit.WindowState)baseValue == Xceed.Wpf.Toolkit.WindowState.Open ? Visibility.Visible : Visibility.Collapsed;
}
return baseValue;
}
}
I did not much of testing but didn’t recognise any side-effects yet. :)