Files
ShrlAlgoToolkit/AntdWpf/Styles/Avatar.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

64 lines
3.8 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:AntdWpf.Controls"
xmlns:helpers="clr-namespace:AntdWpf.Helpers">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Converters.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type controls:Avatar}">
<Setter Property="IsTabStop" Value="False" />
<Setter Property="TextBlock.LineHeight" Value="NaN" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Width" Value="{DynamicResource AvatarSizeBase}" />
<Setter Property="FontFamily" Value="{DynamicResource FontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarFontSizeBase}" />
<Setter Property="Foreground" Value="{DynamicResource AvatarForeground}" />
<Setter Property="Background" Value="{DynamicResource AvatarBackground}" />
<Setter Property="Height" Value="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
<Setter Property="helpers:Control.CornerRadius" Value="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self},
Converter={StaticResource DoubleToCornerRadiusConverter}, ConverterParameter=2}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Avatar}">
<Border Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
CornerRadius="{TemplateBinding helpers:Control.CornerRadius}">
<ContentPresenter x:Name="PART_Content"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Shape" Value="Square">
<Setter Property="helpers:Control.CornerRadius" Value="{DynamicResource AvatarBorderRadius}" />
</Trigger>
<!-- Sizes -->
<Trigger Property="Size" Value="Small">
<Setter Property="Width" Value="{DynamicResource AvatarSizeSmall}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarFontSizeSmall}" />
</Trigger>
<Trigger Property="Size" Value="Large">
<Setter Property="Width" Value="{DynamicResource AvatarSizeLarge}" />
<Setter Property="FontSize" Value="{DynamicResource AvatarFontSizeLarge}" />
</Trigger>
<!-- without icon -->
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="FontSize" Value="{DynamicResource FontSizeBase}" />
</Trigger>
<Trigger Property="IsImage" Value="True">
<Setter Property="Background" Value="Transparent" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>