chore: add avalonia TabControl demo.
This commit is contained in:
1 parent
bbb2db1696
commit
045ced1c73
12 files changed
+685
-87
No files matched your search
@@ -14,7 +14,7 @@
|
|||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
Background="{DynamicResource SecondaryRegionBrush}" />
|
Background="{DynamicResource SecondaryRegionBrush}" />
|
||||||
<TabControl BorderThickness="0 1 0 0"
|
<TabControl BorderThickness="0 1 0 0"
|
||||||
Classes="inline"
|
Theme="{StaticResource TabControlInLine}"
|
||||||
SelectionChanged="TabControl_OnSelectionChanged"
|
SelectionChanged="TabControl_OnSelectionChanged"
|
||||||
ItemsSource="{Binding DemoInfoCollection}"
|
ItemsSource="{Binding DemoInfoCollection}"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
|
|||||||
@@ -0,0 +1,189 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
x:Class="HandyControlDemo.UserControl.NativeTabControlDemo"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||||
|
<ScrollViewer>
|
||||||
|
<hc:UniformSpacingPanel Margin="32"
|
||||||
|
Spacing="32"
|
||||||
|
ItemWidth="400"
|
||||||
|
ItemHeight="200"
|
||||||
|
MaxWidth="832"
|
||||||
|
ChildWrapping="Wrap">
|
||||||
|
<TabControl TabStripPlacement="Right">
|
||||||
|
<TabItem Header="Title1">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="1" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title2"
|
||||||
|
IsEnabled="False">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="2" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title3">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="3" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title4">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="4" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title5">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="5" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
<TabControl Theme="{StaticResource TabControlInLine}">
|
||||||
|
<TabItem Header="Title1">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="1" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title2">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="2" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title3">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="3" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title4">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="4" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title5"
|
||||||
|
IsSelected="True">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="5" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
<TabControl TabStripPlacement="Left"
|
||||||
|
Theme="{StaticResource TabControlCapsule}">
|
||||||
|
<TabItem Header="Title1">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="1" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem IsSelected="True"
|
||||||
|
Header="Title2">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="2" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title3">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="3" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title4">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="4" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title5">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="5" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
<TabControl TabStripPlacement="Bottom"
|
||||||
|
Theme="{StaticResource TabControlCapsuleSolid}">
|
||||||
|
<TabItem Header="Title1">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="1" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem IsEnabled="False"
|
||||||
|
Header="Title2">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="2" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title3">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="3" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem IsSelected="True"
|
||||||
|
Header="Title4">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="4" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
<TabItem Header="Title5">
|
||||||
|
<Border>
|
||||||
|
<TextBlock Theme="{StaticResource TextBlockLargeBold}">
|
||||||
|
<Run Text="Text" />
|
||||||
|
<Run Text="5" />
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
</TabItem>
|
||||||
|
</TabControl>
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</UserControl>
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
namespace HandyControlDemo.UserControl;
|
||||||
|
|
||||||
|
public partial class NativeTabControlDemo : Avalonia.Controls.UserControl
|
||||||
|
{
|
||||||
|
public NativeTabControlDemo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using HandyControl.Tools;
|
||||||
|
|
||||||
|
namespace HandyControl.Controls;
|
||||||
|
|
||||||
|
public class ItemsControlAttach
|
||||||
|
{
|
||||||
|
public static readonly AttachedProperty<ThemeSelector?> ItemsContainerThemeSelectorProperty =
|
||||||
|
AvaloniaProperty.RegisterAttached<ItemsControlAttach, AvaloniaObject, ThemeSelector?>(
|
||||||
|
"ItemsContainerThemeSelector");
|
||||||
|
|
||||||
|
public static void SetItemsContainerThemeSelector(AvaloniaObject element, ThemeSelector? value) =>
|
||||||
|
element.SetValue(ItemsContainerThemeSelectorProperty, value);
|
||||||
|
|
||||||
|
public static ThemeSelector? GetItemsContainerThemeSelector(AvaloniaObject element) =>
|
||||||
|
element.GetValue(ItemsContainerThemeSelectorProperty);
|
||||||
|
|
||||||
|
static ItemsControlAttach()
|
||||||
|
{
|
||||||
|
ItemsContainerThemeSelectorProperty.Changed.AddClassHandler<AvaloniaObject>(
|
||||||
|
OnItemsContainerThemeSelectorChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnItemsContainerThemeSelectorChanged(AvaloniaObject element, AvaloniaPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (element is not ItemsControl itemsControl)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemsControl.ContainerPrepared -= OnContainerPrepared;
|
||||||
|
var themeSelector = e.GetNewValue<ThemeSelector?>();
|
||||||
|
|
||||||
|
if (themeSelector is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
itemsControl.ContainerPrepared += OnContainerPrepared;
|
||||||
|
ApplyTheme(itemsControl, themeSelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnContainerPrepared(object? sender, ContainerPreparedEventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is not ItemsControl itemsControl)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var themeSelector = GetItemsContainerThemeSelector(itemsControl);
|
||||||
|
if (themeSelector is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ApplyTheme(itemsControl, themeSelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ApplyTheme(ItemsControl itemsControl, ThemeSelector themeSelector)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < itemsControl.ItemCount; i++)
|
||||||
|
{
|
||||||
|
var container = itemsControl.ContainerFromIndex(i);
|
||||||
|
if (container != null)
|
||||||
|
{
|
||||||
|
container.Theme = themeSelector.SelectTheme(itemsControl.Items[i], container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,14 @@ namespace HandyControl.Controls;
|
|||||||
|
|
||||||
public class TitleElement
|
public class TitleElement
|
||||||
{
|
{
|
||||||
|
public static readonly AttachedProperty<IBrush?> BorderBrushProperty =
|
||||||
|
AvaloniaProperty.RegisterAttached<TitleElement, AvaloniaObject, IBrush?>("BorderBrush", inherits: true);
|
||||||
|
|
||||||
|
public static void SetBorderBrush(AvaloniaObject element, IBrush? value) =>
|
||||||
|
element.SetValue(BorderBrushProperty, value);
|
||||||
|
|
||||||
|
public static IBrush? GetBorderBrush(AvaloniaObject element) => element.GetValue(BorderBrushProperty);
|
||||||
|
|
||||||
public static readonly AttachedProperty<IBrush?> BackgroundProperty =
|
public static readonly AttachedProperty<IBrush?> BackgroundProperty =
|
||||||
AvaloniaProperty.RegisterAttached<TitleElement, AvaloniaObject, IBrush?>("Background", inherits: true);
|
AvaloniaProperty.RegisterAttached<TitleElement, AvaloniaObject, IBrush?>("Background", inherits: true);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,74 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
<ControlTheme x:Key="{x:Type TabControl}"
|
xmlns:hc="clr-namespace:HandyControl.Controls"
|
||||||
|
xmlns:tools="clr-namespace:HandyControl.Tools"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=System.Runtime">
|
||||||
|
<ControlTheme x:Key="TabItemStyle"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource TitleBrush}" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="{StaticResource DefaultControlPadding}" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="HorizontalContentAlignment"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="VerticalContentAlignment"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<Panel>
|
||||||
|
<Border Name="mainBorder"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="0"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
Margin="0" />
|
||||||
|
<ContentPresenter Name="PART_ContentPresenter"
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Content="{TemplateBinding Header}"
|
||||||
|
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
RecognizesAccessKey="True" />
|
||||||
|
</Panel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^:disabled">
|
||||||
|
<Setter Property="Opacity"
|
||||||
|
Value="0.4" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:selected">
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
<Style Selector="^[TabStripPlacement=Left] /template/ Border#mainBorder">
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="0,0,2,0" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^[TabStripPlacement=Top] /template/ Border#mainBorder">
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="0,0,0,2" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^[TabStripPlacement=Right] /template/ Border#mainBorder">
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="2,0,0,0" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^[TabStripPlacement=Bottom] /template/ Border#mainBorder">
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="0,2,0,0" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabControlBaseStyle"
|
||||||
TargetType="TabControl">
|
TargetType="TabControl">
|
||||||
<Setter Property="BorderBrush"
|
<Setter Property="BorderBrush"
|
||||||
Value="{DynamicResource BorderBrush}" />
|
Value="{DynamicResource BorderBrush}" />
|
||||||
@@ -8,6 +76,8 @@
|
|||||||
Value="{DynamicResource RegionBrush}" />
|
Value="{DynamicResource RegionBrush}" />
|
||||||
<Setter Property="BorderThickness"
|
<Setter Property="BorderThickness"
|
||||||
Value="1" />
|
Value="1" />
|
||||||
|
<Setter Property="ItemContainerTheme"
|
||||||
|
Value="{StaticResource TabItemStyle}" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate>
|
<ControlTemplate>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
@@ -46,29 +116,290 @@
|
|||||||
Value="Left" />
|
Value="Left" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel">
|
|
||||||
<Setter Property="Orientation"
|
|
||||||
Value="Vertical" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="^[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter">
|
<Style Selector="^[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter">
|
||||||
<Setter Property="DockPanel.Dock"
|
<Setter Property="DockPanel.Dock"
|
||||||
Value="Right" />
|
Value="Right" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel">
|
||||||
|
<Setter Property="Orientation"
|
||||||
|
Value="Vertical" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
<Style Selector="^[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel">
|
<Style Selector="^[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter > WrapPanel">
|
||||||
<Setter Property="Orientation"
|
<Setter Property="Orientation"
|
||||||
Value="Vertical" />
|
Value="Vertical" />
|
||||||
</Style>
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
<Style Selector="^.inline">
|
<ControlTheme x:Key="{x:Type TabControl}"
|
||||||
|
BasedOn="{StaticResource TabControlBaseStyle}"
|
||||||
|
TargetType="TabControl" />
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemInLine"
|
||||||
|
BasedOn="{StaticResource TabItemStyle}"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="MinWidth"
|
||||||
|
Value="0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabControlInLine"
|
||||||
|
BasedOn="{StaticResource TabControlBaseStyle}"
|
||||||
|
TargetType="TabControl">
|
||||||
|
<Setter Property="ItemContainerTheme"
|
||||||
|
Value="{StaticResource TabItemInLine}" />
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Left], ^[TabStripPlacement=Right]">
|
||||||
<Setter Property="ItemsPanel">
|
<Setter Property="ItemsPanel">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<UniformGrid Rows="1"/>
|
<UniformGrid Rows="0"
|
||||||
|
Columns="1" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Top], ^[TabStripPlacement=Bottom]">
|
||||||
|
<Setter Property="ItemsPanel">
|
||||||
|
<Setter.Value>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<UniformGrid Rows="1"
|
||||||
|
Columns="0" />
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleBaseStyle"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource BorderBrush}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource PrimaryTextBrush}" />
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="1" />
|
||||||
|
<Setter Property="VerticalAlignment"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="VerticalContentAlignment"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="HorizontalContentAlignment"
|
||||||
|
Value="Center" />
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="0" />
|
||||||
|
<Setter Property="CornerRadius"
|
||||||
|
Value="{Binding $self.(hc:BorderElement.CornerRadius)}" />
|
||||||
|
<Setter Property="MinHeight"
|
||||||
|
Value="{StaticResource DefaultControlHeight}" />
|
||||||
|
<Setter Property="Padding"
|
||||||
|
Value="10,0" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="-1,0,0,0" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<Border x:Name="rootBorder"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}">
|
||||||
|
<ContentPresenter Name="PART_ContentPresenter"
|
||||||
|
Padding="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Content="{TemplateBinding Header}"
|
||||||
|
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
|
RecognizesAccessKey="True" />
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^:disabled">
|
||||||
|
<Setter Property="Opacity"
|
||||||
|
Value="0.4" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:pointerover">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource SecondaryRegionBrush}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^:selected">
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{Binding $self.(hc:TitleElement.Background)}" />
|
||||||
|
<Setter Property="Foreground"
|
||||||
|
Value="{Binding $self.(hc:TitleElement.Foreground)}" />
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{Binding $self.(hc:TitleElement.BorderBrush)}" />
|
||||||
|
<Setter Property="ZIndex"
|
||||||
|
Value="{x:Static system:Int32.MaxValue}" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Left], ^[TabStripPlacement=Right]">
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0,-1,0,0" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^[TabStripPlacement=Top], ^[TabStripPlacement=Bottom]">
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="-1,0,0,0" />
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleDefault"
|
||||||
|
BasedOn="{StaticResource TabItemCapsuleBaseStyle}"
|
||||||
|
TargetType="TabItem" />
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleHorizontalFirst"
|
||||||
|
BasedOn="{StaticResource TabItemCapsuleBaseStyle}"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="4,0,0,4" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleHorizontalLast"
|
||||||
|
BasedOn="{StaticResource TabItemCapsuleBaseStyle}"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="0,4,4,0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleSingle"
|
||||||
|
BasedOn="{StaticResource TabItemCapsuleBaseStyle}"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="{StaticResource DefaultCornerRadius}" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleVerticalFirst"
|
||||||
|
BasedOn="{StaticResource TabItemCapsuleBaseStyle}"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="4,4,0,0" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabItemCapsuleVerticalLast"
|
||||||
|
BasedOn="{StaticResource TabItemCapsuleBaseStyle}"
|
||||||
|
TargetType="TabItem">
|
||||||
|
<Setter Property="hc:BorderElement.CornerRadius"
|
||||||
|
Value="0,0,4,4" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabControlCapsule"
|
||||||
|
TargetType="TabControl">
|
||||||
|
<Setter Property="BorderThickness"
|
||||||
|
Value="1" />
|
||||||
|
<Setter Property="Background"
|
||||||
|
Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush"
|
||||||
|
Value="{DynamicResource BorderBrush}" />
|
||||||
|
<Setter Property="hc:TitleElement.BorderBrush"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
<Setter Property="hc:TitleElement.Background"
|
||||||
|
Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="hc:TitleElement.Foreground"
|
||||||
|
Value="{DynamicResource PrimaryBrush}" />
|
||||||
|
<Setter Property="hc:ItemsControlAttach.ItemsContainerThemeSelector">
|
||||||
|
<Setter.Value>
|
||||||
|
<tools:TabItemCapsuleThemeSelector />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate>
|
||||||
|
<DockPanel>
|
||||||
|
<ItemsPresenter Name="PART_ItemsPresenter"
|
||||||
|
ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||||
|
<Border Padding="{TemplateBinding Padding}"
|
||||||
|
Margin="0,6,0,0"
|
||||||
|
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||||
|
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
BorderBrush="{TemplateBinding BorderBrush}"
|
||||||
|
BorderThickness="{TemplateBinding BorderThickness}"
|
||||||
|
CornerRadius="{TemplateBinding CornerRadius}">
|
||||||
|
<ContentPresenter Name="PART_SelectedContentHost"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Content="{TemplateBinding SelectedContent}"
|
||||||
|
ContentTemplate="{TemplateBinding SelectedContentTemplate}" />
|
||||||
|
</Border>
|
||||||
|
</DockPanel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Top] /template/ ItemsPresenter#PART_ItemsPresenter">
|
||||||
|
<Setter Property="DockPanel.Dock"
|
||||||
|
Value="Top" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0,0,0,6" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Bottom] /template/ ItemsPresenter#PART_ItemsPresenter">
|
||||||
|
<Setter Property="DockPanel.Dock"
|
||||||
|
Value="Bottom" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0,6,0,0" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Left] /template/ ItemsPresenter#PART_ItemsPresenter">
|
||||||
|
<Setter Property="DockPanel.Dock"
|
||||||
|
Value="Left" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="0,0,6,0" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Right] /template/ ItemsPresenter#PART_ItemsPresenter">
|
||||||
|
<Setter Property="DockPanel.Dock"
|
||||||
|
Value="Right" />
|
||||||
|
<Setter Property="Margin"
|
||||||
|
Value="6,0,0,0" />
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Left], ^[TabStripPlacement=Right]">
|
||||||
|
<Setter Property="ItemsPanel">
|
||||||
|
<Setter.Value>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<UniformGrid Rows="0"
|
||||||
|
Columns="1"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="^[TabStripPlacement=Top], ^[TabStripPlacement=Bottom]">
|
||||||
|
<Setter Property="ItemsPanel">
|
||||||
|
<Setter.Value>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<UniformGrid Rows="1"
|
||||||
|
Columns="0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
|
<ControlTheme x:Key="TabControlCapsuleSolid"
|
||||||
|
BasedOn="{StaticResource TabControlCapsule}"
|
||||||
|
TargetType="TabControl">
|
||||||
|
<Setter Property="hc:TitleElement.BorderBrush"
|
||||||
|
Value="{DynamicResource TitleBrush}" />
|
||||||
|
<Setter Property="hc:TitleElement.Background"
|
||||||
|
Value="{DynamicResource TitleBrush}" />
|
||||||
|
<Setter Property="hc:TitleElement.Foreground"
|
||||||
|
Value="{DynamicResource TextIconBrush}" />
|
||||||
|
</ControlTheme>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ControlTheme x:Key="{x:Type TabItem}"
|
|
||||||
TargetType="TabItem">
|
|
||||||
<Setter Property="Foreground"
|
|
||||||
Value="{DynamicResource PrimaryTextBrush}" />
|
|
||||||
<Setter Property="Background"
|
|
||||||
Value="{DynamicResource RegionBrush}" />
|
|
||||||
<Setter Property="BorderBrush"
|
|
||||||
Value="{DynamicResource TitleBrush}" />
|
|
||||||
<Setter Property="Margin"
|
|
||||||
Value="0" />
|
|
||||||
<Setter Property="Padding"
|
|
||||||
Value="{StaticResource DefaultControlPadding}" />
|
|
||||||
<Setter Property="MinHeight"
|
|
||||||
Value="{StaticResource DefaultControlHeight}" />
|
|
||||||
<Setter Property="HorizontalContentAlignment"
|
|
||||||
Value="Center" />
|
|
||||||
<Setter Property="VerticalContentAlignment"
|
|
||||||
Value="Center" />
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate>
|
|
||||||
<Panel>
|
|
||||||
<Border Name="mainBorder"
|
|
||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
|
||||||
BorderThickness="0"
|
|
||||||
Background="{TemplateBinding Background}"
|
|
||||||
Margin="0" />
|
|
||||||
<ContentPresenter Name="PART_ContentPresenter"
|
|
||||||
Padding="{TemplateBinding Padding}"
|
|
||||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
||||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
||||||
Content="{TemplateBinding Header}"
|
|
||||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
|
||||||
CornerRadius="{TemplateBinding CornerRadius}"
|
|
||||||
RecognizesAccessKey="True" />
|
|
||||||
</Panel>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
|
|
||||||
<Style Selector="^:disabled">
|
|
||||||
<Setter Property="Opacity"
|
|
||||||
Value="0.4" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<Style Selector="^:selected">
|
|
||||||
<Setter Property="Foreground"
|
|
||||||
Value="{DynamicResource PrimaryBrush}" />
|
|
||||||
|
|
||||||
<Style Selector="^ /template/ Border#mainBorder">
|
|
||||||
<Setter Property="BorderThickness"
|
|
||||||
Value="0,0,0,2" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</ControlTheme>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
<MergeResourceInclude Source="/Themes/Styles/CheckBox.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/CheckBox.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/Border.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/Border.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/ItemsControl.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/ItemsControl.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/TabItem.axaml" />
|
|
||||||
<MergeResourceInclude Source="/Themes/Styles/TabControl.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/TabControl.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/ScrollViewer.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/ScrollViewer.axaml" />
|
||||||
<MergeResourceInclude Source="/Themes/Styles/ListBox.axaml" />
|
<MergeResourceInclude Source="/Themes/Styles/ListBox.axaml" />
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Styling;
|
||||||
|
using HandyControl.Data;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools;
|
||||||
|
|
||||||
|
public class TabItemCapsuleThemeSelector : ThemeSelector
|
||||||
|
{
|
||||||
|
public override ControlTheme? SelectTheme(object? item, AvaloniaObject? container)
|
||||||
|
{
|
||||||
|
if (container is not TabItem { Parent: TabControl tabControl } tabItem)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = tabControl.Items.Count;
|
||||||
|
if (count == 1)
|
||||||
|
{
|
||||||
|
return ResourceHelper.GetResource<ControlTheme>(ResourceToken.TabItemCapsuleSingle);
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = tabControl.IndexFromContainer(tabItem);
|
||||||
|
return index == 0
|
||||||
|
? ResourceHelper.GetResource<ControlTheme>(
|
||||||
|
tabControl.TabStripPlacement is Dock.Top or Dock.Bottom
|
||||||
|
? ResourceToken.TabItemCapsuleHorizontalFirst
|
||||||
|
: ResourceToken.TabItemCapsuleVerticalFirst)
|
||||||
|
: ResourceHelper.GetResource<ControlTheme>(index == count - 1
|
||||||
|
? tabControl.TabStripPlacement is Dock.Top or Dock.Bottom
|
||||||
|
? ResourceToken.TabItemCapsuleHorizontalLast
|
||||||
|
: ResourceToken.TabItemCapsuleVerticalLast
|
||||||
|
: ResourceToken.TabItemCapsuleDefault);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Styling;
|
||||||
|
|
||||||
|
namespace HandyControl.Tools;
|
||||||
|
|
||||||
|
public class ThemeSelector
|
||||||
|
{
|
||||||
|
public virtual ControlTheme? SelectTheme(object? item, AvaloniaObject? container) => null;
|
||||||
|
}
|
||||||
@@ -189,6 +189,7 @@
|
|||||||
<Style x:Key="TabControlCapsule" TargetType="TabControl">
|
<Style x:Key="TabControlCapsule" TargetType="TabControl">
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="Background" Value="{DynamicResource RegionBrush}" />
|
||||||
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}" />
|
||||||
<Setter Property="hc:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="hc:TitleElement.BorderBrush" Value="{DynamicResource PrimaryBrush}" />
|
||||||
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource RegionBrush}" />
|
<Setter Property="hc:TitleElement.Background" Value="{DynamicResource RegionBrush}" />
|
||||||
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
|
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource PrimaryBrush}" />
|
||||||
@@ -210,7 +211,7 @@
|
|||||||
<RowDefinition x:Name="RowDefinition1" Height="*" />
|
<RowDefinition x:Name="RowDefinition1" Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<UniformGrid Rows="1" KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0"/>
|
<UniformGrid Rows="1" KeyboardNavigation.TabNavigation="Once" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="0" Grid.Row="0"/>
|
||||||
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{DynamicResource BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1">
|
<Border x:Name="contentPanel" Margin="0,6,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Grid.Column="0" Grid.Row="1">
|
||||||
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -8,27 +8,28 @@ public class TabItemCapsuleStyleSelector : StyleSelector
|
|||||||
{
|
{
|
||||||
public override Style SelectStyle(object item, DependencyObject container)
|
public override Style SelectStyle(object item, DependencyObject container)
|
||||||
{
|
{
|
||||||
if (container is TabItem tabItem && VisualHelper.GetParent<TabControl>(tabItem) is { } tabControl)
|
if (container is not TabItem tabItem || VisualHelper.GetParent<TabControl>(tabItem) is not { } tabControl)
|
||||||
{
|
{
|
||||||
var count = tabControl.Items.Count;
|
return null;
|
||||||
if (count == 1)
|
|
||||||
{
|
|
||||||
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.TabItemCapsuleSingle);
|
|
||||||
}
|
|
||||||
|
|
||||||
var index = tabControl.ItemContainerGenerator.IndexFromContainer(tabItem);
|
|
||||||
return index == 0
|
|
||||||
? ResourceHelper.GetResourceInternal<Style>(
|
|
||||||
tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
|
||||||
? ResourceToken.TabItemCapsuleHorizontalFirst
|
|
||||||
: ResourceToken.TabItemCapsuleVerticalFirst)
|
|
||||||
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
|
||||||
? tabControl.TabStripPlacement == Dock.Top || tabControl.TabStripPlacement == Dock.Bottom
|
|
||||||
? ResourceToken.TabItemCapsuleHorizontalLast
|
|
||||||
: ResourceToken.TabItemCapsuleVerticalLast
|
|
||||||
: ResourceToken.TabItemCapsuleDefault);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
var count = tabControl.Items.Count;
|
||||||
|
if (count == 1)
|
||||||
|
{
|
||||||
|
return ResourceHelper.GetResourceInternal<Style>(ResourceToken.TabItemCapsuleSingle);
|
||||||
|
}
|
||||||
|
|
||||||
|
var index = tabControl.ItemContainerGenerator.IndexFromContainer(tabItem);
|
||||||
|
return index == 0
|
||||||
|
? ResourceHelper.GetResourceInternal<Style>(
|
||||||
|
tabControl.TabStripPlacement is Dock.Top or Dock.Bottom
|
||||||
|
? ResourceToken.TabItemCapsuleHorizontalFirst
|
||||||
|
: ResourceToken.TabItemCapsuleVerticalFirst)
|
||||||
|
: ResourceHelper.GetResourceInternal<Style>(index == count - 1
|
||||||
|
? tabControl.TabStripPlacement is Dock.Top or Dock.Bottom
|
||||||
|
? ResourceToken.TabItemCapsuleHorizontalLast
|
||||||
|
: ResourceToken.TabItemCapsuleVerticalLast
|
||||||
|
: ResourceToken.TabItemCapsuleDefault);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user