Files
ShrlAlgoToolkit/WPFluent/Controls/RatingControl/RatingControl.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

96 lines
4.9 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type controls:RatingControl}">
<!-- Universal WPF UI focus -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<!-- Universal WPF UI focus -->
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorAttentionBrush}" />
<Setter Property="FontSize" Value="20" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:RatingControl}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="StarsContainer">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<controls:SymbolIcon
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Grid.Column="0"
Symbol="Star28"
x:Name="PART_Star1" />
<controls:SymbolIcon
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Grid.Column="1"
Symbol="Star28"
x:Name="PART_Star2" />
<controls:SymbolIcon
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Grid.Column="2"
Symbol="Star28"
x:Name="PART_Star3" />
<controls:SymbolIcon
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Grid.Column="3"
Symbol="Star28"
x:Name="PART_Star4" />
<controls:SymbolIcon
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Grid.Column="4"
Symbol="Star28"
x:Name="PART_Star5" />
</Grid>
<Grid
Grid.Column="1"
Margin="8,0,0,0"
VerticalAlignment="Center"
x:Name="ContentGrid">
<ContentPresenter TextElement.FontSize="13" TextElement.Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Content" Value="{x:Null}">
<Setter Property="Margin" TargetName="ContentGrid" Value="0" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" TargetName="StarsContainer" Value="0.5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>