Sample:
When a window is created, IsVisible is being set to true, then to false, and then back to true. When I add a new window, the prior window sets its visibility to false, and then sets it to true.
If I have logic that fires when the window becomes visible, it may fire twice under this scenario.
If I'm looking to find when a window is made visible, is there a different event I should be watching or an easy way to work around this?
Thank you,
Mick
<Window
x:Class="DocumentWindowIsVisibleChanged.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<docking:DockSite Name="docksite">
<docking:Workspace>
<docking:TabbedMdiHost>
<docking:TabbedMdiContainer />
</docking:TabbedMdiHost>
</docking:Workspace>
</docking:DockSite>
<Button Grid.Row="1" Content="Create new window and dock" Click="Button_Click" />
</Grid>
</Window>
using System;
using System.Windows;
using ActiproSoftware.Windows.Controls.Docking;
using System.Collections.Generic;
using System.Windows.Controls;
namespace DocumentWindowIsVisibleChanged
{
public partial class MainWindow : Window
{
int windowNumber = 0;
private static string calls = string.Empty;
public MainWindow() { InitializeComponent(); }
private void Button_Click(object sender, RoutedEventArgs e)
{
calls = string.Empty;
DocumentWindow dw = new DocumentWindow(docksite, "window" + windowNumber, "window" + windowNumber, null, null) { Tag = "window" + windowNumber };
dw.IsVisibleChanged += dw_IsVisibleChanged;
dw.Activate();
MessageBox.Show(calls, "DocumentWindow.IsVisibleChanged call History");
windowNumber++;
}
private void dw_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
calls += string.Format("{0}: OldValue={1}, NewValue={2}{3}", (string)((DocumentWindow)sender).Tag, e.OldValue, e.NewValue, Environment.NewLine);
}
}
}
If I have logic that fires when the window becomes visible, it may fire twice under this scenario.
If I'm looking to find when a window is made visible, is there a different event I should be watching or an easy way to work around this?
Thank you,
Mick