Dragablz icon indicating copy to clipboard operation
Dragablz copied to clipboard

Prevent MDI children user control from overflowing their container on init

Open lucasg opened this issue 6 years ago • 2 comments

Hi,

I recently use your dragablz/dockablz library and I can't find a way to prevent child user controls that are floating items from overflowing the tab control container on init. An exemple of this undesirable behaviour :

image

This is the example code :

MainWindow.xaml :

<Window x:Class="OverflowMDIChild.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:OverflowMDIChild"
        xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
        xmlns:dockablz="clr-namespace:Dragablz.Dockablz;assembly=Dragablz"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Grid x:Name="MainGrid" Margin="0,0,0,0" Background="#FF5C8F88">
        <Grid.RowDefinitions>
            <RowDefinition Height="200*"/>
        </Grid.RowDefinitions>
        
        <dockablz:Layout Partition="2AE89D18-F236-4D20-9605-6C03319038E6" Name="FloatLayout"
                    IsFloatDropZoneEnabled="False"
                    FloatingItemHeaderMemberPath="Header"
                    FloatingItemsContainerMargin="0 0 0 0"
                    Grid.Row="0">

            <dockablz:Layout.FloatingItems>
            </dockablz:Layout.FloatingItems>

        </dockablz:Layout>
    </Grid>
</Window>

MainWindow.xaml.cs :

using System.Windows;


namespace OverflowMDIChild
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var NoOverflowChild = new OverflowingChildren
            {
                Header = "NonOverflowing mdi child demo",
                Content = "A\nA\nA\nA\nA",
            };

            var OverflowChild = new OverflowingChildren
            {
                Header = "Overflowing mdi child demo",
                Content = "A\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\nA\n",
            };
            
            this.FloatLayout.FloatingItems.Add(NoOverflowChild);
            this.FloatLayout.FloatingItems.Add(OverflowChild);
        }
    }
}

OverflowingChildren.xaml :

<UserControl x:Class="OverflowMDIChild.OverflowingChildren"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:OverflowMDIChild"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid x:Name="ResizeElemGrid" Margin="0,0,0,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="146*"></RowDefinition>
        </Grid.RowDefinitions>

        <TextBlock Name="OverflowContent"
                   Grid.Row="0"
                   Text="{Binding Content}"
                   >
        </TextBlock>
    </Grid>
</UserControl>

OverflowingChildren.xaml.cs :

using System.Windows.Controls;


namespace OverflowMDIChild
{
    /// <summary>
    /// Logique d'interaction pour OverflowingChildren.xaml
    /// </summary>
    public partial class OverflowingChildren : UserControl
    {
        
        public string Header
        {
            get; set;
        }
    }
}

This is not great UX : the user has to manually resize every newly created child items in order to fit them into the container view. Is there a way to do it with dragablz ?

L.

N.B. : I'm okay with allowing child items overflow the dockablz on user drag or resize actions afterwards (since the user is the one purposelly doing the action).

lucasg avatar Oct 08 '17 13:10 lucasg