This project is read-only.
1
Vote

Maximize Layout Anchroable

description

Hi,

am developing a project with the help of avalondock. I have three layouts in screen. i want to hide all two and show the third one in the screen fully.

<avalonDock:DockingManager x:Name="DManager" Style="{StaticResource DockingManagerStyle}">
        <avalonDock:DockingManager.Resources>
            <Style TargetType="{x:Type avalonDock:AnchorablePaneTitle}">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border Background="#1E6EAD" Height="22"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"  
                                             Padding="0,4,0,4" Margin="-4">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="20"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock ToolTip="{Binding Path=Content.ToolTip}" Text="{Binding Title}" Margin="5,0,0,0" VerticalAlignment="Center" Foreground="White" x:Name="txtTitle"/>
                                    <Button x:Name="PART_HidePin" Margin="2,0,4,0"                                                
                            Grid.Column="1" 
                            Height="15" Width="13"
                            Style="{StaticResource ButtonStyle}"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Command="{Binding Path=LayoutItem.HideCommand, RelativeSource={RelativeSource TemplatedParent}}" 
                            Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={StaticResource VConverter}}"
                            ToolTip="Hide">
                                        <Viewbox Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center" Height="11" >
                                            <Path Fill="White" Data="M20.535,17.294L34.002,3.827c0.781-0.781,0.781-2.047,0-2.828c-0.78-0.781-2.048-0.781-2.828,0L17.707,14.466L4.242,0.999
        c-0.78-0.781-2.047-0.781-2.828,0s-0.781,2.047,0,2.828l13.465,13.467L0.586,31.587c-0.781,0.781-0.781,2.047,0,2.828
        c0.39,0.391,0.902,0.586,1.414,0.586s1.024-0.195,1.414-0.586l14.293-14.293L32,34.415c0.391,0.391,0.902,0.586,1.414,0.586
        s1.023-0.195,1.414-0.586c0.781-0.781,0.781-2.047,0-2.828L20.535,17.294z"/>
                                        </Viewbox>
                                    </Button>
                                    <avalonDock:DropDownButton Margin="2"
                            x:Name="MenuDropDownButton"
                            VerticalAlignment="Center"
                            Style="{StaticResource DropDownStyle}"
                            Focusable="False"
                            Grid.Column="2"                                
                            DropDownContextMenuDataContext="{Binding Path=LayoutItem, RelativeSource={RelativeSource TemplatedParent}}"
                            ToolTip="Window Position">
                                        <Viewbox Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Top" Height="12" Width="12">
                                            <Polygon Fill="White" Points="0,63.75 127.5,191.25 255,63.75"/>
                                        </Viewbox>
                                        <avalonDock:DropDownButton.DropDownContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="Detach" x:Name="DetachMenu"
                                              Command="{Binding Path=FloatCommand}"/>
                                                <MenuItem Header="Attach" 
                                               Command="{Binding Path=DockCommand}"/>
                                                <MenuItem Header="Maximize" Click="MenuItem_Click" Tag="{Binding Source={x:Reference txtTitle}, Path=Text}"/>
                                            </ContextMenu>
                                        </avalonDock:DropDownButton.DropDownContextMenu>
                                    </avalonDock:DropDownButton>
                                    <Button Grid.Column="3" ToolTip="Restore" x:Name="btnRestore" Click="btnRestore_Click" Height="13" Width="13" Style="{StaticResource ButtonStyle}" IsEnabled="{Binding IsMaximize, RelativeSource={RelativeSource Self}}">
                                        <Viewbox Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center" Height="12" >
                                            <Path Fill="White" Data="M2,2H16V16H2V2M22,8V22H8V18H10V20H20V10H18V8H22Z"/>
                                        </Viewbox>
                                    </Button>
                                </Grid>
                            </Border>
                            <ControlTemplate.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Model.IsAutoHidden}" Value="True">
                                    <Setter TargetName="btnRestore" Property="Visibility" Value="Hidden"/>
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </avalonDock:DockingManager.Resources>
        <avalonDock:LayoutRoot x:Name="_layoutRoot1">
            <avalonDock:LayoutPanel Orientation="Vertical">
                <avalonDock:LayoutPanel Orientation="Horizontal" x:Name="jobGrid">
                    <avalonDock:LayoutAnchorablePaneGroup DockWidth="34*">
                        <avalonDock:LayoutAnchorablePane x:Name="JobPane" >
                            <avalonDock:LayoutAnchorable x:Name="jobLstLayout"   Title="JOB LIST CONTROL" CanHide="True"   ContentId="JobControl"  Hiding="Layout_Hiding" >
                                <Button Content="Testing" x:Name="btnTesting" IsEnabled="{Binding IsMaximize, UpdateSourceTrigger=PropertyChanged}" Height="35" Width="150"/>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorablePane>
                    </avalonDock:LayoutAnchorablePaneGroup>
                    <avalonDock:LayoutAnchorablePaneGroup  DockWidth="66*">
                        <avalonDock:LayoutAnchorablePane  x:Name="MapPane">
                            <avalonDock:LayoutAnchorable  x:Name="mapLayout"   Title="MAP CONTROL" ContentId= "MapControl"  Hiding="Layout_Hiding" CanHide="True">
                                <Grid x:Name="DockMapCtrl">

                                </Grid>
                            </avalonDock:LayoutAnchorable>
                        </avalonDock:LayoutAnchorablePane>
                    </avalonDock:LayoutAnchorablePaneGroup>
                </avalonDock:LayoutPanel>
                <avalonDock:LayoutAnchorablePaneGroup>
                    <avalonDock:LayoutAnchorablePane   x:Name="TechPane">
                        <avalonDock:LayoutAnchorable x:Name="techLayout"  Title="TECHNICIAN CALENDER" ContentId= "TechListControl"  Hiding="Layout_Hiding" CanHide="True">

                        </avalonDock:LayoutAnchorable>
                    </avalonDock:LayoutAnchorablePane>
                </avalonDock:LayoutAnchorablePaneGroup>
            </avalonDock:LayoutPanel>
        </avalonDock:LayoutRoot>
    </avalonDock:DockingManager>
private void MaximizeLayoutAnchorableByName(string ContentId)
    {
        List<LayoutAnchorable> Max = new List<LayoutAnchorable>();
        LayoutPanel ContentLayout = null;
        foreach (LayoutAnchorable Layout in DManager.Layout.Descendents().OfType<LayoutAnchorable>())
        {
            if (Layout.Title != ContentId) Max.Add(Layout);
            else
            {
                if (ContentLayout == null) ContentLayout = Layout.Parent.FindParent<LayoutPanel>();
            }
        }

        foreach (LayoutAnchorable lyout in Max)
        {                
            lyout.Hide();                                
        }                

        if (ContentLayout.Descendents().OfType<LayoutPanel>().Count() >= 1)
        {
            LayoutPanel LPanel = ContentLayout.Descendents().OfType<LayoutPanel>().First();
            LPanel.DockMinHeight = 0;
            DManager.GridSplitterHeight = 0;
            LPanel.DockHeight = new GridLength(0, GridUnitType.Star);
        }

    }
private void MenuItem_Click(object sender, RoutedEventArgs e)
    {
        ((MenuItem)sender).IsEnabled = false;
        MaximizeLayoutAnchorableByName(((MenuItem)sender).Tag.ToString());            
    }

Everything is working fine, but the maximize button is not disabling. if i comment lyout.hide() method then its working, but how to hide remaining panels in the screen

comments