SelectionChanged Stops Firing After Last Window Closed

Docking/MDI for WPF Forum

Posted 11 years ago by Andy Ver Murlen
Version: 4.5.0485
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
Avatar
The SelectionChanged event on a DockingWindowContainer stops firing after the last window is closed, and then new windows are added to it...

<Window
    x:Class="RibbonSample.Window1"
    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="Window1">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button Content="Add Window" Click="Button_Click" />
        <Grid Grid.Row="1">
            <docking:DockSite x:Name="uxDockSite_DockSite">
                <docking:Workspace>
                    <docking:TabbedMdiHost>
                        <docking:TabbedMdiContainer SelectionChanged="uxTabbedMdiContainer_TabContainer_SelectionChanged">                       
                            <docking:DocumentWindow Title="One" Content="One"/>
                            <docking:DockingWindow Title="Two" Content="Two" />
                            <docking:DockingWindow Title="Three" Content="Three"/>
                            <docking:DockingWindow Title="Four" Content="Four"/>
                        </docking:TabbedMdiContainer>
                    </docking:TabbedMdiHost>
                </docking:Workspace>
            </docking:DockSite>
        </Grid>
    </Gri

using System;
using System.Windows;
using System.Windows.Controls;
using ActiproSoftware.Windows.Controls.Docking;

namespace RibbonSample
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void uxTabbedMdiContainer_TabContainer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Console.WriteLine("Selection Changed");
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DocumentWindow window = new DocumentWindow(uxDockSite_DockSite);
            window.Title = "New Window";
            window.Activate();
        }
    }
}
Flip between the windows, and you will see "Selection Changed" output to the output window. Close all the windows and click the add button a few times. You will no longer see the selection changed event.

Comments (1)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Andy,

That is correct, basically for the same reason I posted in reply to your previous message. TabbedMdiContainers are added/removed dynamically at run-time. This must be done to properly support docking functionality.

If you want to track events then you should be using ones like DockSite.WindowFocused, etc.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.