ButchersBoy / Dragablz

Dragable and tearable tab control for WPF
http://dragablz.net
MIT License
2.17k stars 321 forks source link

Closed tabs still take space #229

Open JasShao opened 4 years ago

JasShao commented 4 years ago

I found that when i close tabs, the tab still take space. When I commented the scrollviewer, it worked well.

<Style TargetType="{x:Type dragablz:DragablzItemsControl}" 
              x:Key="TabablzDragablzItemsControlStyle">
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Top" />
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <Canvas IsItemsHost="True" />
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type dragablz:DragablzItemsControl}">
                            <Border BorderThickness="{TemplateBinding Border.BorderThickness}" Padding="{TemplateBinding Control.Padding}" BorderBrush="{TemplateBinding Border.BorderBrush}" Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
                                <!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left"
                                      Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type dragablz:DragablzItemsControl}},Path= ActualWidth}"
                                      Height="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type dragablz:DragablzItemsControl}},Path= ActualHeight}"
                                      Template="{StaticResource TabablzScrollViewerControlTemplate}">-->
                                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
                                            HorizontalAlignment="Left"
                                            VerticalAlignment="Top"
                                            Width="{TemplateBinding ItemsPresenterWidth}"
                                            Height="{TemplateBinding ItemsPresenterHeight}"/>
                                <!--</ScrollViewer>-->
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
codingdna2 commented 4 years ago

I know the issue is old, but maybe it can be of help to someone.

The sizing is made by the {TemplateBinding ItemsPresenterWidth} and {Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type dragablz:DragablzItemsControl}},Path= ActualWidth} which are controlled by the TabablzHeaderSizeConverter applied on dragablz:DragablzItemsControl. I guess you should post the relevant part.