Skip to content

Commit e0b8823

Browse files
committed
allow content to be added to the left, right, top and bottom of the tabstrip.
1 parent f9dadd0 commit e0b8823

4 files changed

Lines changed: 177 additions & 30 deletions

File tree

src/Dock.Avalonia.Themes.Browser/Styles/BrowserTabAccents.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
<Thickness x:Key="DockDocumentTabStripHorizontalCreateButtonMargin">6,0</Thickness>
144144
<Thickness x:Key="DockDocumentTabStripHorizontalScrollViewerMargin">0</Thickness>
145145
<Thickness x:Key="DockDocumentTabStripHorizontalScrollViewerPadding">0</Thickness>
146+
<Thickness x:Key="DockHostWindowContentPadding">6</Thickness>
146147
<Thickness x:Key="DockToolChromeTitleMargin">0,4,8,4</Thickness>
147148
<sys:Double x:Key="DockTargetSelectorSize">40</sys:Double>
148149
<sys:Double x:Key="DockTargetSelectorGridMaxSize">125</sys:Double>

src/Dock.Avalonia.Themes.Browser/Styles/Controls/HostWindow.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<Setter Property="(DockProperties.DockGroup)" Value="{Binding DockGroup}" />
2020

2121
<Setter Property="Background" Value="{DynamicResource DockSurfaceEditorBrush}" />
22+
<Setter Property="Padding" Value="{DynamicResource DockHostWindowContentPadding}" />
2223
<Setter Property="(TextElement.FontSize)" Value="{DynamicResource DockFontSizeNormal}" />
2324
<Setter Property="TextBlock.Foreground" Value="{DynamicResource DockTabForegroundBrush}" />
2425
<Setter Property="WindowState" Value="Normal" />

src/Dock.Avalonia.Themes.Fluent/Controls/DocumentTabStrip.axaml

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,36 +68,61 @@
6868

6969
<Setter Property="Template">
7070
<ControlTemplate>
71-
<DockPanel Background="{TemplateBinding Background}"
72-
ClipToBounds="False">
73-
<Panel DockPanel.Dock="Left"
74-
Width="{DynamicResource DockDocumentTabStripLeadingSpacerWidth}"
75-
Height="1" />
76-
<Panel Name="PART_Panel">
77-
<ScrollViewer x:Name="PART_ScrollViewer">
78-
<ItemsPresenter x:Name="PART_ItemsPresenter"
79-
ItemsPanel="{TemplateBinding ItemsPanel}" />
80-
</ScrollViewer>
81-
<Border Name="PART_BorderFill"
82-
DockProperties.IsDropArea="True"
83-
DockProperties.IsDockTarget="True"
84-
DockProperties.ShowDockIndicatorOnly="True"
85-
DockProperties.IndicatorDockOperation="Fill">
86-
<Border.Margin>
87-
<MultiBinding Converter="{x:Static BorderFillMarginConverter.Instance}">
88-
<Binding Path="#PART_ItemsPresenter.Bounds.Width" />
89-
<Binding Path="#PART_ItemsPresenter.Bounds.Height" />
90-
<Binding Path="#PART_ItemsPresenter.IsVisible" />
91-
<Binding Path="#PART_ItemsPresenter.VerticalAlignment" />
92-
<Binding Path="#PART_ItemsPresenter.HorizontalAlignment" />
93-
</MultiBinding>
94-
</Border.Margin>
95-
</Border>
96-
</Panel>
97-
<ContentControl x:Name="PART_CreateButtonHost"
98-
Content="{Binding}"
99-
IsVisible="{Binding CanCreateDocument}" />
100-
</DockPanel>
71+
<Grid Background="{TemplateBinding Background}"
72+
ClipToBounds="False"
73+
RowDefinitions="Auto,*,Auto"
74+
ColumnDefinitions="Auto,*,Auto">
75+
<ContentPresenter Grid.Row="0"
76+
Grid.Column="0"
77+
Grid.ColumnSpan="3"
78+
Content="{TemplateBinding TopContent}"
79+
ContentTemplate="{TemplateBinding TopContentTemplate}" />
80+
<ContentPresenter Grid.Row="1"
81+
Grid.Column="0"
82+
Content="{TemplateBinding LeftContent}"
83+
ContentTemplate="{TemplateBinding LeftContentTemplate}" />
84+
<ContentPresenter Grid.Row="1"
85+
Grid.Column="2"
86+
Content="{TemplateBinding RightContent}"
87+
ContentTemplate="{TemplateBinding RightContentTemplate}" />
88+
<ContentPresenter Grid.Row="2"
89+
Grid.Column="0"
90+
Grid.ColumnSpan="3"
91+
Content="{TemplateBinding BottomContent}"
92+
ContentTemplate="{TemplateBinding BottomContentTemplate}" />
93+
94+
<DockPanel Grid.Row="1"
95+
Grid.Column="1"
96+
ClipToBounds="False">
97+
<Panel DockPanel.Dock="Left"
98+
Width="{DynamicResource DockDocumentTabStripLeadingSpacerWidth}"
99+
Height="1" />
100+
<Panel Name="PART_Panel">
101+
<ScrollViewer x:Name="PART_ScrollViewer">
102+
<ItemsPresenter x:Name="PART_ItemsPresenter"
103+
ItemsPanel="{TemplateBinding ItemsPanel}" />
104+
</ScrollViewer>
105+
<Border Name="PART_BorderFill"
106+
DockProperties.IsDropArea="True"
107+
DockProperties.IsDockTarget="True"
108+
DockProperties.ShowDockIndicatorOnly="True"
109+
DockProperties.IndicatorDockOperation="Fill">
110+
<Border.Margin>
111+
<MultiBinding Converter="{x:Static BorderFillMarginConverter.Instance}">
112+
<Binding Path="#PART_ItemsPresenter.Bounds.Width" />
113+
<Binding Path="#PART_ItemsPresenter.Bounds.Height" />
114+
<Binding Path="#PART_ItemsPresenter.IsVisible" />
115+
<Binding Path="#PART_ItemsPresenter.VerticalAlignment" />
116+
<Binding Path="#PART_ItemsPresenter.HorizontalAlignment" />
117+
</MultiBinding>
118+
</Border.Margin>
119+
</Border>
120+
</Panel>
121+
<ContentControl x:Name="PART_CreateButtonHost"
122+
Content="{Binding}"
123+
IsVisible="{Binding CanCreateDocument}" />
124+
</DockPanel>
125+
</Grid>
101126
</ControlTemplate>
102127
</Setter>
103128

src/Dock.Avalonia/Controls/DocumentTabStrip.axaml.cs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,54 @@ public class DocumentTabStrip : TabStrip
7070
public static readonly StyledProperty<IDataTemplate?> CreateButtonTemplateProperty =
7171
AvaloniaProperty.Register<DocumentTabStrip, IDataTemplate?>(nameof(CreateButtonTemplate));
7272

73+
/// <summary>
74+
/// Defines the <see cref="LeftContent"/> property.
75+
/// </summary>
76+
public static readonly StyledProperty<object?> LeftContentProperty =
77+
AvaloniaProperty.Register<DocumentTabStrip, object?>(nameof(LeftContent));
78+
79+
/// <summary>
80+
/// Defines the <see cref="TopContent"/> property.
81+
/// </summary>
82+
public static readonly StyledProperty<object?> TopContentProperty =
83+
AvaloniaProperty.Register<DocumentTabStrip, object?>(nameof(TopContent));
84+
85+
/// <summary>
86+
/// Defines the <see cref="RightContent"/> property.
87+
/// </summary>
88+
public static readonly StyledProperty<object?> RightContentProperty =
89+
AvaloniaProperty.Register<DocumentTabStrip, object?>(nameof(RightContent));
90+
91+
/// <summary>
92+
/// Defines the <see cref="BottomContent"/> property.
93+
/// </summary>
94+
public static readonly StyledProperty<object?> BottomContentProperty =
95+
AvaloniaProperty.Register<DocumentTabStrip, object?>(nameof(BottomContent));
96+
97+
/// <summary>
98+
/// Defines the <see cref="LeftContentTemplate"/> property.
99+
/// </summary>
100+
public static readonly StyledProperty<IDataTemplate?> LeftContentTemplateProperty =
101+
AvaloniaProperty.Register<DocumentTabStrip, IDataTemplate?>(nameof(LeftContentTemplate));
102+
103+
/// <summary>
104+
/// Defines the <see cref="TopContentTemplate"/> property.
105+
/// </summary>
106+
public static readonly StyledProperty<IDataTemplate?> TopContentTemplateProperty =
107+
AvaloniaProperty.Register<DocumentTabStrip, IDataTemplate?>(nameof(TopContentTemplate));
108+
109+
/// <summary>
110+
/// Defines the <see cref="RightContentTemplate"/> property.
111+
/// </summary>
112+
public static readonly StyledProperty<IDataTemplate?> RightContentTemplateProperty =
113+
AvaloniaProperty.Register<DocumentTabStrip, IDataTemplate?>(nameof(RightContentTemplate));
114+
115+
/// <summary>
116+
/// Defines the <see cref="BottomContentTemplate"/> property.
117+
/// </summary>
118+
public static readonly StyledProperty<IDataTemplate?> BottomContentTemplateProperty =
119+
AvaloniaProperty.Register<DocumentTabStrip, IDataTemplate?>(nameof(BottomContentTemplate));
120+
73121
/// <summary>
74122
/// Gets or sets the create button theme.
75123
/// </summary>
@@ -88,6 +136,78 @@ public IDataTemplate? CreateButtonTemplate
88136
set => SetValue(CreateButtonTemplateProperty, value);
89137
}
90138

139+
/// <summary>
140+
/// Gets or sets content displayed to the left side of the tab strip.
141+
/// </summary>
142+
public object? LeftContent
143+
{
144+
get => GetValue(LeftContentProperty);
145+
set => SetValue(LeftContentProperty, value);
146+
}
147+
148+
/// <summary>
149+
/// Gets or sets content displayed above the tab strip.
150+
/// </summary>
151+
public object? TopContent
152+
{
153+
get => GetValue(TopContentProperty);
154+
set => SetValue(TopContentProperty, value);
155+
}
156+
157+
/// <summary>
158+
/// Gets or sets content displayed to the right side of the tab strip.
159+
/// </summary>
160+
public object? RightContent
161+
{
162+
get => GetValue(RightContentProperty);
163+
set => SetValue(RightContentProperty, value);
164+
}
165+
166+
/// <summary>
167+
/// Gets or sets content displayed below the tab strip.
168+
/// </summary>
169+
public object? BottomContent
170+
{
171+
get => GetValue(BottomContentProperty);
172+
set => SetValue(BottomContentProperty, value);
173+
}
174+
175+
/// <summary>
176+
/// Gets or sets template for <see cref="LeftContent"/>.
177+
/// </summary>
178+
public IDataTemplate? LeftContentTemplate
179+
{
180+
get => GetValue(LeftContentTemplateProperty);
181+
set => SetValue(LeftContentTemplateProperty, value);
182+
}
183+
184+
/// <summary>
185+
/// Gets or sets template for <see cref="TopContent"/>.
186+
/// </summary>
187+
public IDataTemplate? TopContentTemplate
188+
{
189+
get => GetValue(TopContentTemplateProperty);
190+
set => SetValue(TopContentTemplateProperty, value);
191+
}
192+
193+
/// <summary>
194+
/// Gets or sets template for <see cref="RightContent"/>.
195+
/// </summary>
196+
public IDataTemplate? RightContentTemplate
197+
{
198+
get => GetValue(RightContentTemplateProperty);
199+
set => SetValue(RightContentTemplateProperty, value);
200+
}
201+
202+
/// <summary>
203+
/// Gets or sets template for <see cref="BottomContent"/>.
204+
/// </summary>
205+
public IDataTemplate? BottomContentTemplate
206+
{
207+
get => GetValue(BottomContentTemplateProperty);
208+
set => SetValue(BottomContentTemplateProperty, value);
209+
}
210+
91211
/// <summary>
92212
/// Gets or sets if tab strop dock can create new items.
93213
/// </summary>

0 commit comments

Comments
 (0)