DocumentWindow IsVisibleChanged fires multiple times

Docking/MDI for WPF Forum

Posted 13 years ago by Mick
Version: 11.1.0545

    Title="MainWindow" Height="350" Width="525">
            <RowDefinition />
            <RowDefinition Height="auto" />
        <docking:DockSite Name="docksite">
                    <docking:TabbedMdiContainer />
        <Button Grid.Row="1" Content="Create new window and dock" Click="Button_Click" />

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;

            MessageBox.Show(calls, "DocumentWindow.IsVisibleChanged call History");


        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);
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,

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Mick,

Sorry for the delay, I didn't receive a notification of your post.

You would probably be better off using DockSite.WindowOpened/WindowClosed instead. The DocumentWindow is only responsible for rendering it's tab, not it's content. So the DocumentWindow may still be visible, while not selected. In addition, when floated there is no tab for DocumentWindows, so technically it would not be visible.

If there is something on your content that needs to know when it's visible, then you could attach to it's IsVisibleChanged event instead.

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.