ContainerMinSize is not reflected after close and re-open floating window

Docking/MDI for WPF Forum

Posted 6 months ago by Yuki
Version: 23.1.4
Platform: .NET 6.0
Environment: Windows 10 (64-bit)
Avatar

Hello,

ContainerMinSize is not reflected after the following steps.

Would you please check it?

If our usage is wrong, please let me know.


1. Float Document Window.

2. Close the floating DocumentWindow.

3. Click "Show DocumenWindow" button in ToolWindow.

4. Resize the floating window

  --> ContainerMinSize is not reflected

  

<Xaml>

<Window
    x:Class="DockingMinContainerSizeSample.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="MainWindow"
    Width="800"
    Height="450"
    mc:Ignorable="d">
    <Grid>
        <!--  Outer  -->
        <docking:DockSite
            x:Name="MainDockSite"
            AreDocumentWindowsDestroyedOnClose="False"
            CanDocumentWindowsFloat="True"
            CanToolWindowsFloat="True">
            <docking:SplitContainer>
                <docking:Workspace>
                    <docking:TabbedMdiHost>
                        <docking:TabbedMdiContainer>
                            <docking:DocumentWindow
                                x:Name="DocumentWindow1"
                                Title="Document1"
                                ContainerMinSize="400,200">
                                <Label Content="Document1" />
                            </docking:DocumentWindow>
                        </docking:TabbedMdiContainer>
                    </docking:TabbedMdiHost>
                </docking:Workspace>

                <docking:ToolWindowContainer>
                    <docking:ToolWindow Title="ToolWindow">
                        <Grid>
                            <Button
                                HorizontalAlignment="Left"
                                VerticalAlignment="Top"
                                Click="Button_Click"
                                Content="Show DocumentWindow" />
                        </Grid>
                    </docking:ToolWindow>
                </docking:ToolWindowContainer>
            </docking:SplitContainer>
        </docking:DockSite>
    </Grid>
</Window>

<Code behind>

#nullable enable

namespace DockingMinContainerSizeSample
{
    using System.Windows;

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            DocumentWindow1?.Open();
        }
    }
}

[Modified 6 months ago]

Comments (10)

Answer - Posted 6 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thank you for reporting this.  We fixed the issue for the next maintenance release.


Actipro Software Support

Posted 6 months ago by Yuki
Avatar

Thanks.

Posted 6 months ago by Yuki
Avatar

Hello,

Would you please check floating window which is opened by layout deserialization?

It seems that ContainerMinSize is not reflected.

  

I checked sample project of "Layout Deserialization".

  • Change point of source code
    • MainControl.xaml
      • Add `CanToolWindowsFloat="True"` to dockSite.
      • Add `ContainerMinSize="200,400"` to solutionExplorerToolWindow.
  • Steps
    • 1. Float `Solution Explorer`.
    • 2. Execute `Layout` menu --> `Save Layout`.
    • 3. Close `Solution Explorer`.
    • 4. Execute `Layout menu` --> `Load Layout`.
      --> I can change `Solution Explorer` smaller than (200,400).
Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Thank you, we have fixed that issue for the next maintenance release.


Actipro Software Support

Posted 5 months ago by Yuki
Avatar

Hello,

I checked with preview build.

Floating tool window was ok, but floating document window still has problem.

Would you please check it?

[Modified 5 months ago]

Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

I did a similar test in the same sample by making the DocumentWindow have ContainerMinSize="400,400" and when saving the layout and including document data (make sure you uncheck the Layout menu item "Only Save ToolWindow Layout"), then navigating to another sample and back, it seemed to load the 400x400 minimum for the floating document.

If you see otherwise with the preview build, please give detailed steps on how to reproduce it so we can see the same.  Thank you.


Actipro Software Support

Posted 5 months ago by Yuki
Avatar

Hello,

  

Thank you for your checking.

In addition to this steps, please change the sample project as the following.

  • Change point of source code
    • MainControl.xaml
      • Add `CanDocuementWindowsFloat="True"` to dockSite.
      • Add `ContainerMinSize="200,400"` to document window which title is "Saved Layout XML".
  • Steps
    • 1. Float document window of `Saved Layout XML`.
    • 2. Uncheck `Layout` menu --> `Only Save TooWindow Layout`
    • 3. Execute `Layout` menu --> `Save Layout`.
    • 4. Execute `Layout` menu --> `Reload Default Layout`.
    • 5. Execute `Layout menu` --> `Load Layout`.
      --> I can change document window of `Saved Layout XML` smaller than (200,400).
Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Yuki,

Thank you for the updated steps.  I did those steps with our latest unreleased codebase (which I believe you have a preview build of) and it would not let me size the floating document under (200,400) size.  It appears to be working as expected here.


Actipro Software Support

Posted 5 months ago by Yuki
Avatar

Hello,


We set ContainerMinSize only when the window is floating.

I could reproduce the issue on sample project if I removed ContainerMinSize from document window and added the following style to document window.

Would you please check it?

<docking:DocumentWindow.Style>
    <Style TargetType="docking:DocumentWindow">
        <Style.Triggers>
            <Trigger Property="IsFloating" Value="True">
                <Setter Property="ContainerMinSize">
                    <Setter.Value>
                        <Size>
                            400
                            400
                        </Size>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
</docking:DocumentWindow.Style>

Whole source code of MainControl.xaml: 

<sampleBrowser:ProductItemControl
    x:Class="ActiproSoftware.ProductSamples.DockingSamples.QuickStart.LayoutSerialization.MainControl"
    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"
    xmlns:sampleBrowser="clr-namespace:ActiproSoftware.SampleBrowser"
    xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared">

    <sampleBrowser:ProductItemControl.Resources>

        <!--  Converters  -->
        <shared:ImageConverter x:Key="ImageConverter" />

    </sampleBrowser:ProductItemControl.Resources>

    <sampleBrowser:ProductItemControl.SideBarContent>
        <StackPanel>

            <Expander Style="{StaticResource SampleHeaderDescriptionExpanderStyle}">
                <TextBlock Style="{StaticResource SampleHeaderDescriptionTextBlockStyle}">
                    This QuickStart shows how you can persist the layout of docking windows.
                    Layout data is typically saved when an application is closed and then restored when the application is reopened.
                    Layout data can also be used to restore a default layout.<LineBreak /><LineBreak />
                    In this particular sample, the layout data is maintained in a static member variable.
                    Change the layout by dragging tool windows to other locations.
                    Then switch to another sample and switch back to this sample.
                    You should see the same tool window layout as when you last left the sample.<LineBreak /><LineBreak />
                    By default, only the layout of the tool windows is retained, but this can be changed via a serializer option.
                    By unchecking the Only Save ToolWindow Layout menu item, the entire layout, including documents and the MDI, can be saved and restored.
                    Each docking window also has a CanSerialize property that can be set to false to prevent it from being included in the layout data.<LineBreak /><LineBreak />
                    There are also three Layout menu items that determine how unknown windows in a layout are handled.
                    This situation occurs in this sample when a programmatic tool window is added, then the sample is switched, and reopened.
                    In that scenario, the programmatic tool window isn't known to the DockSite, but it has layout data in the XML.
                    The layout data can be discarded (default), auto-created, or lazy loaded.<LineBreak /><LineBreak />
                    Since the layout data of this sample is saved in a static member variable,
                    changes are not maintained if the entire Sample Browser application is closed.
                    That behavior can easily be updated to save the layout to a file instead.</TextBlock>
            </Expander>

        </StackPanel>
    </sampleBrowser:ProductItemControl.SideBarContent>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!--  DockSite  -->
        <docking:DockSite
            x:Name="dockSite"
            Grid.Row="1"
            CanDocumentWindowsFloat="True"
            CanToolWindowsFloat="True">
            <docking:DockSite.AutoHideLeftContainers>
                <docking:ToolWindowContainer>
                    <docking:ToolWindow
                        x:Name="toolboxToolWindow"
                        Title="Toolbox"
                        ImageSource="/Images/Icons/Toolbox16.png">
                        <TextBlock
                            Margin="5"
                            Text="Place toolbox items here."
                            TextWrapping="Wrap" />
                    </docking:ToolWindow>
                </docking:ToolWindowContainer>
            </docking:DockSite.AutoHideLeftContainers>

            <docking:SplitContainer>

                <!--  Workspace  -->
                <docking:Workspace>
                    <docking:TabbedMdiHost x:Name="tabbedMdiHost">
                        <docking:TabbedMdiContainer>
                            <docking:DocumentWindow
                                Title="Saved Layout XML"
                                CanClose="False"
                                ImageSource="/Images/Icons/TextDocument16.png"
                                SerializationId="LayoutDataDocument">
                                <docking:DocumentWindow.Style>
                                    <Style TargetType="docking:DocumentWindow">
                                        <Style.Triggers>
                                            <Trigger Property="IsFloating" Value="True">
                                                <Setter Property="ContainerMinSize">
                                                    <Setter.Value>
                                                        <Size>
                                                            400
                                                            400
                                                        </Size>
                                                    </Setter.Value>
                                                </Setter>
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </docking:DocumentWindow.Style>
                                <TextBox
                                    x:Name="layoutXmlTextBox"
                                    AcceptsReturn="True"
                                    BorderThickness="0"
                                    HorizontalScrollBarVisibility="Auto"
                                    IsReadOnly="True"
                                    VerticalScrollBarVisibility="Auto" />
                            </docking:DocumentWindow>
                        </docking:TabbedMdiContainer>
                    </docking:TabbedMdiHost>
                </docking:Workspace>

                <docking:ToolWindowContainer>
                    <docking:ToolWindow
                        x:Name="solutionExplorerToolWindow"
                        Title="Solution Explorer"
                        ContainerMinSize="200,400"
                        ImageSource="/Images/Icons/SolutionExplorer16.png">
                        <TreeView BorderThickness="0">
                            <TreeViewItem Header="Solution 'Actipro Controls' (1 project)" IsExpanded="True">
                                <TreeViewItem Header="ControlsSample" IsExpanded="True">
                                    <TreeViewItem Header="Properties" />
                                    <TreeViewItem Header="References" />
                                    <TreeViewItem Header="Demo.cs" />
                                </TreeViewItem>
                            </TreeViewItem>
                        </TreeView>
                    </docking:ToolWindow>
                    <docking:ToolWindow
                        x:Name="classViewToolWindow"
                        Title="Class View"
                        ImageSource="/Images/Icons/ClassView16.png">
                        <TreeView BorderThickness="0">
                            <TreeViewItem Header="ControlsSample" IsExpanded="True">
                                <TreeViewItem Header="Project References" />
                                <TreeViewItem Header="ActiproSoftware.ProductSamples.DockingSamples" />
                                <TreeViewItem Header="ActiproSoftware.ProductSamples.EditorsSamples" />
                                <TreeViewItem Header="ActiproSoftware.ProductSamples.SharedSamples" />
                                <TreeViewItem Header="ActiproSoftware.SampleBrowser" />
                                <TreeViewItem Header="XamlGeneratedNamespace" />
                            </TreeViewItem>
                        </TreeView>
                    </docking:ToolWindow>
                    <docking:ToolWindow
                        x:Name="documentOutlineToolWindow"
                        Title="Document Outline"
                        ImageSource="/Images/Icons/DocumentOutline16.png">
                        <TextBox
                            BorderThickness="0"
                            IsReadOnly="True"
                            Text="(not available)"
                            TextWrapping="Wrap" />
                    </docking:ToolWindow>
                </docking:ToolWindowContainer>
            </docking:SplitContainer>

        </docking:DockSite>

        <!--  Menu  -->
        <shared:PixelSnapper>
            <Menu>
                <MenuItem Header="_Layout">
                    <MenuItem
                        x:Name="saveToolWindowLayoutOnlyMenuItem"
                        Click="OnSaveLayoutMenuItemClick"
                        Header="Only Save ToolWindow Layout"
                        IsCheckable="True"
                        IsChecked="True" />
                    <MenuItem
                        Click="OnSaveLayoutMenuItemClick"
                        Header="Can Serialize Class View"
                        IsCheckable="True"
                        IsChecked="{Binding ElementName=classViewToolWindow, Path=CanSerialize, Mode=TwoWay}" />
                    <Separator />
                    <MenuItem
                        x:Name="discardMenuItem"
                        Click="OnWindowDeserializationOptionMenuItemClick"
                        Header="Discard Unknown Windows"
                        IsChecked="True" />
                    <MenuItem
                        x:Name="autoCreateMenuItem"
                        Click="OnWindowDeserializationOptionMenuItemClick"
                        Header="Auto-Create Unknown Windows" />
                    <MenuItem
                        x:Name="lazyLoadMenuItem"
                        Click="OnWindowDeserializationOptionMenuItemClick"
                        Header="Lazy Load Unknown Windows" />
                    <Separator />
                    <MenuItem Click="OnLoadDefaultLayoutMenuItemClick" Header="Reload Default Layout" />
                    <Separator />
                    <MenuItem Click="OnLoadLayoutMenuItemClick" Header="Load Layout" />
                    <MenuItem Click="OnSaveLayoutMenuItemClick" Header="Save Layout" />
                </MenuItem>
                <MenuItem Header="_Activate">
                    <MenuItem
                        x:Name="activeProgrammaticToolWindow1"
                        Click="OnActivateProgrammaticToolWindow1Click"
                        Header="Create Programmatic ToolWindow 1"
                        Icon="{Binding Source='pack://application:,,,/SampleBrowser;component/Images/Icons/Properties16.png', Converter={StaticResource ImageConverter}}" />
                    <MenuItem
                        x:Name="activeProgrammaticToolWindow2"
                        Click="OnActivateProgrammaticToolWindow2Click"
                        Header="Create Programmatic ToolWindow 2"
                        Icon="{Binding Source='pack://application:,,,/SampleBrowser;component/Images/Icons/Properties16.png', Converter={StaticResource ImageConverter}}" />
                    <Separator />
                    <MenuItem
                        Command="{Binding ElementName=classViewToolWindow, Path=ActivateCommand}"
                        Header="Activate Class View"
                        Icon="{Binding Source='pack://application:,,,/SampleBrowser;component/Images/Icons/ClassView16.png', Converter={StaticResource ImageConverter}}" />
                    <MenuItem
                        Command="{Binding ElementName=documentOutlineToolWindow, Path=ActivateCommand}"
                        Header="Activate Document Outline"
                        Icon="{Binding Source='pack://application:,,,/SampleBrowser;component/Images/Icons/DocumentOutline16.png', Converter={StaticResource ImageConverter}}" />
                    <MenuItem
                        Command="{Binding ElementName=solutionExplorerToolWindow, Path=ActivateCommand}"
                        Header="Activate Solution Explorer"
                        Icon="{Binding Source='pack://application:,,,/SampleBrowser;component/Images/Icons/SolutionExplorer16.png', Converter={StaticResource ImageConverter}}" />
                    <MenuItem
                        Command="{Binding ElementName=toolboxToolWindow, Path=ActivateCommand}"
                        Header="Activate Toolbox"
                        Icon="{Binding Source='pack://application:,,,/SampleBrowser;component/Images/Icons/Toolbox16.png', Converter={StaticResource ImageConverter}}" />
                </MenuItem>
            </Menu>
        </shared:PixelSnapper>

    </Grid>

</sampleBrowser:ProductItemControl>
Posted 5 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

In that new case, during layout deserialization, the DockingWindow.IsFloating property was updated after all the container sizes were examined, meaning the trigger fired too late.  We've updated our deserialization code to do one more examination of container sizes after properties like IsFloating are updated, which resolves this case.


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.