feat: classes Line, Left, Center, Right.

This commit is contained in:
Zhang Dian 2024-01-26 17:54:40 +08:00
parent 547d733f84
commit d9c39cdd05
2 changed files with 20 additions and 15 deletions

View File

@ -34,8 +34,8 @@
<Border Padding="4" Background="Transparent">
<Ellipse
Name="Container"
Width="{DynamicResource CarouselIndicatorSelectedHeight}"
Height="{DynamicResource CarouselIndicatorSelectedHeight}"
Width="{DynamicResource CarouselIndicatorWidth}"
Height="{DynamicResource CarouselIndicatorHeight}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{TemplateBinding Foreground}" />
@ -61,18 +61,12 @@
<Setter Property="ListBoxItem.Template">
<ControlTemplate TargetType="ListBoxItem">
<Panel Background="Transparent">
<Border Padding="4,0" Background="Transparent">
<Border Padding="2,0" Background="Transparent">
<Border
Name="Container"
Width="{DynamicResource CarouselIndicatorSelectedHeight}"
Height="{DynamicResource CarouselIndicatorSelectedHeight}"
Background="{TemplateBinding Background}"
CornerRadius="99">
<Border.Transitions>
<Transitions>
<DoubleTransition Property="Width" Duration="0:0:0.2" />
</Transitions>
</Border.Transitions>
Width="{DynamicResource CarouselIndicatorLineWidth}"
Height="{DynamicResource CarouselIndicatorLineHeight}"
Background="{TemplateBinding Background}">
</Border>
</Border>
</Panel>
@ -86,7 +80,6 @@
</Style>
<Style Selector="^:selected /template/ Border#Container">
<Setter Property="Background" Value="{DynamicResource CarouselIndicatorSelectedForeground}" />
<Setter Property="Width" Value="{DynamicResource CarouselIndicatorLineSelectedWidth}" />
</Style>
</ControlTheme>
@ -179,6 +172,14 @@
</Setter>
<Style Selector="^.Line /template/ ListBox#PART_ItemsPresenter2">
<Setter Property="ItemContainerTheme" Value="{DynamicResource CarouselIndicatorLineListBoxItem}" />
<Style Selector="^.Left /template/ ListBox#PART_ItemsPresenter2">
<Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style Selector="^.Center /template/ ListBox#PART_ItemsPresenter2">
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style Selector="^.Right /template/ ListBox#PART_ItemsPresenter2">
<Setter Property="HorizontalAlignment" Value="Right" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@ -1,7 +1,11 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<PathGeometry x:Key="CarouselButtonGlyph">M16.2782 4.23933C16.864 4.82511 16.864 5.77486 16.2782 6.36065L10.6213 12.0175L16.2782 17.6744C16.864 18.2601 16.864 19.2099 16.2782 19.7957C15.6924 20.3815 14.7426 20.3815 14.1569 19.7957L7.43934 13.0782C6.85355 12.4924 6.85355 11.5426 7.43934 10.9568L14.1569 4.23933C14.7426 3.65354 15.6924 3.65354 16.2782 4.23933Z</PathGeometry>
<x:Double x:Key="CarouselIndicatorLineSelectedWidth">48</x:Double>
<x:Double x:Key="CarouselIndicatorSelectedHeight">8</x:Double>
<x:Double x:Key="CarouselIndicatorWidth">8</x:Double>
<x:Double x:Key="CarouselIndicatorHeight">8</x:Double>
<x:Double x:Key="CarouselIndicatorLineWidth">78</x:Double>
<x:Double x:Key="CarouselIndicatorLineHeight">4</x:Double>
<Thickness x:Key="CarouselButtonMargin">8</Thickness>
</ResourceDictionary>