Files
ShrlAlgoToolkit/AntDesignWPF/Controls/Avatar/Avatar.xaml
2025-07-31 20:12:24 +08:00

67 lines
3.9 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:AntDesignWPF.Controls"
xmlns:helpers="clr-namespace:AntDesignWPF.Helpers"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Themes/Converters.xaml" />
<!--<ResourceDictionary Source="pack://application:,,,/AntDesignWPF;component/Resources/BaseBrushes/Cyan.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 AntDesign.Brush.TextOnPrimary}" />
<Setter Property="Background" Value="{DynamicResource AntDesign.Brush.TextQuaternary}" />
<Setter Property="Height" Value="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
<Setter Property="helpers:AntControl.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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding helpers:AntControl.CornerRadius}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="PART_Content" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Shape" Value="Square">
<Setter Property="helpers:AntControl.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>