Files
Ursa.Avalonia/src/Ursa.Themes.Semi/Controls/Rating.axaml
2024-06-07 11:04:06 +08:00

72 lines
3.6 KiB
XML

<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<ControlTheme x:Key="{x:Type u:RatingCharacter}" TargetType="u:RatingCharacter">
<Setter Property="Character" Value="{DynamicResource RatingStarIconGlyph}" />
<Setter Property="Background" Value="{DynamicResource RatingCharacterBackground}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Template">
<ControlTemplate TargetType="u:RatingCharacter">
<!-- <Border Margin="0 0 6 0"> -->
<Canvas Width="24" Height="24">
<Path Width="24"
Height="24"
Data="{TemplateBinding Character}"
Fill="{TemplateBinding Background}" />
<Border Name="{x:Static u:RatingCharacter.PART_IconGlyph}"
IsVisible="False"
ClipToBounds="True">
<Path Width="24"
Height="24"
HorizontalAlignment="Left"
Data="{TemplateBinding Character}"
Fill="{TemplateBinding Foreground}" />
</Border>
</Canvas>
<!-- </Border> -->
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="RenderTransform" Value="scale(1.1)" />
</Style>
<Style Selector="^:selected /template/ Border#PART_IconGlyph">
<Setter Property="IsVisible" Value="True" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:Rating}" TargetType="u:Rating">
<Setter Property="Foreground" Value="{DynamicResource RatingCharacterForeground}" />
<Setter Property="Character" Value="{DynamicResource RatingStarIconGlyph}" />
<Setter Property="ItemTemplate">
<DataTemplate>
<u:RatingCharacter />
</DataTemplate>
</Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:Rating">
<Border Name="PART_RootBorder"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel HorizontalAlignment="Stretch">
<ItemsControl Name="{x:Static u:Rating.PART_ItemsControl}"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
ItemTemplate="{TemplateBinding ItemTemplate}"
ItemsSource="{TemplateBinding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Panel>
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>