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

104 lines
6.2 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thickness x:Key="CardControlPadding">14,16,14,16</Thickness>
<Thickness x:Key="CardControlBorderThemeThickness">1</Thickness>
<Thickness x:Key="CardControlIconMargin">0,0,14,0</Thickness>
<Thickness x:Key="CardControlContentMargin">14,0,0,0</Thickness>
<system:Double x:Key="CardControlIconSize">24.0</system:Double>
<Style TargetType="{x:Type controls:CardControl}" x:Key="DefaultUiCardControlStyle">
<!-- Universal WPF UI focus -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<!-- Universal WPF UI focus -->
<Setter Property="Background" Value="{DynamicResource CardBackgroundFillColorDefaultBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource CardStrokeColorDefaultBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource CardControlBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource CardControlPadding}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:CardControl}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Height="{TemplateBinding Height}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
MinHeight="{TemplateBinding MinHeight}"
MinWidth="{TemplateBinding MinWidth}"
Padding="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Width="{TemplateBinding Width}"
x:Name="ContentBorder">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentControl
Content="{TemplateBinding Icon}"
Focusable="False"
FontSize="{StaticResource CardControlIconSize}"
Foreground="{TemplateBinding Foreground}"
Grid.Column="0"
KeyboardNavigation.IsTabStop="False"
Margin="{StaticResource CardControlIconMargin}"
VerticalAlignment="Center"
x:Name="ControlIcon" />
<ContentPresenter
Content="{TemplateBinding Header}"
Grid.Column="1"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalAlignment="Center"
x:Name="HeaderContentPresenter" />
<ContentPresenter
Content="{TemplateBinding Content}"
Grid.Column="2"
Margin="{StaticResource CardControlContentMargin}"
TextElement.Foreground="{TemplateBinding Foreground}"
VerticalAlignment="Center"
x:Name="ContentPresenter" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Content" Value="{x:Null}">
<Setter Property="Margin" TargetName="ContentPresenter" Value="0" />
</Trigger>
<Trigger Property="Content" Value="">
<Setter Property="Margin" TargetName="ContentPresenter" Value="0" />
</Trigger>
<Trigger Property="Header" Value="{x:Null}">
<Setter Property="Margin" TargetName="ControlIcon" Value="0" />
</Trigger>
<Trigger Property="Header" Value="">
<Setter Property="Margin" TargetName="ControlIcon" Value="0" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Margin" TargetName="ControlIcon" Value="0" />
<Setter Property="Visibility" TargetName="ControlIcon" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultUiCardControlStyle}" TargetType="{x:Type controls:CardControl}" />
</ResourceDictionary>