Files
29WxOrder/Main.Test/Dictionary2.xaml
T
2026-09-02 13:45:52 +08:00

428 lines
18 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol">
<!-- DataGrid -->
<SolidColorBrush x:Key="ColumnHeaderBackgroundBrush" Color="#FAFAFA" />
<SolidColorBrush x:Key="ColumnHeaderBorderBrush" Color="#FAFAFA" />
<Style
x:Key="DataGridColumnHeader.MarginSmall"
BasedOn="{StaticResource DataGridColumnHeaderStyle}"
TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
<Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
<Setter Property="Padding" Value="6,0" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="BorderThickness" Value="0,0,1,1" />
<Setter Property="BorderBrush" Value="{Binding VerticalGridLinesBrush, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<hc:SimplePanel SnapsToDevicePixels="True">
<Border
Padding="{TemplateBinding Padding}"
Background="{StaticResource ColumnHeaderBackgroundBrush}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="True"
UseLayoutRounding="True">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
VerticalAlignment="Center"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<ToggleButton
x:Name="ToggleButtonSortDirection"
Grid.Column="1"
Width="20"
Padding="4,0"
VerticalAlignment="Center"
hc:IconSwitchElement.Geometry="{StaticResource DownGeometry}"
hc:IconSwitchElement.GeometrySelected="{StaticResource UpGeometry}"
Foreground="{DynamicResource TextIconBrush}"
IsEnabled="False"
Opacity="1"
Style="{StaticResource ToggleButtonIconTransparent}" />
</Grid>
</Border>
<Thumb
x:Name="PART_LeftHeaderGripper"
HorizontalAlignment="Left"
Style="{StaticResource ColumnHeaderGripperStyle}" />
<Thumb
x:Name="PART_RightHeaderGripper"
HorizontalAlignment="Right"
Style="{StaticResource ColumnHeaderGripperStyle}" />
</hc:SimplePanel>
<ControlTemplate.Triggers>
<Trigger Property="SortDirection" Value="{x:Null}">
<Setter TargetName="ToggleButtonSortDirection" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="SortDirection" Value="Ascending">
<Setter TargetName="ToggleButtonSortDirection" Property="IsChecked" Value="True" />
</Trigger>
<Trigger Property="SortDirection" Value="Descending">
<Setter TargetName="ToggleButtonSortDirection" Property="IsChecked" Value="False" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
行样式:不再手工画顶部边框,横线统一交给 DataGrid.HorizontalGridLinesBrush 处理,
避免行/单元格分层画线导致的交界处错位、断线问题。
-->
<Style
x:Key="DataGridRowStyle.MarginSmall"
BasedOn="{StaticResource DataGridRowStyle}"
TargetType="{x:Type DataGridRow}">
<Setter Property="Margin" Value="0,0,0,0" />
</Style>
<Style
x:Key="DataGridRowStyle.Rightangle"
BasedOn="{StaticResource DataGridRowStyle.MarginSmall}"
TargetType="{x:Type DataGridRow}">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRow}">
<SelectiveScrollingGrid>
<SelectiveScrollingGrid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</SelectiveScrollingGrid.ColumnDefinitions>
<SelectiveScrollingGrid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</SelectiveScrollingGrid.RowDefinitions>
<Border
Name="DGR_Border"
Background="{TemplateBinding Background}"
CornerRadius="0"
SelectiveScrollingGrid.ColumnSpan="2"
SnapsToDevicePixels="True" />
<DataGridCellsPresenter
MinHeight="{TemplateBinding MinHeight}"
VerticalContentAlignment="Center"
ItemsPanel="{TemplateBinding ItemsPanel}"
SelectiveScrollingGrid.Column="1"
SelectiveScrollingGrid.Row="0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<DataGridDetailsPresenter
Margin="0,6"
SelectiveScrollingGrid.Column="1"
SelectiveScrollingGrid.Row="1"
SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}"
Visibility="{TemplateBinding DetailsVisibility}" />
<DataGridRowHeader
SelectiveScrollingGrid.Column="0"
SelectiveScrollingGrid.Row="0"
SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Row}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
</SelectiveScrollingGrid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--
单元格样式:去掉自绘右边框,竖线统一交给 DataGrid.VerticalGridLinesBrush 处理。
-->
<Style
x:Key="DataGridCellStyle.Rightangle"
BasedOn="{StaticResource DataGridCellStyle}"
TargetType="{x:Type DataGridCell}">
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
<Setter Property="Margin" Value="0,0,0,0" />
</Style>
<!-- {x:Type DataGrid} -->
<Style
x:Key="DataGrid.Custom"
BasedOn="{StaticResource DataGridBaseStyle}"
TargetType="{x:Type DataGrid}">
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle.Rightangle}" />
<Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle.Rightangle}" />
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeader.MarginSmall}" />
<Setter Property="BorderBrush" Value="{StaticResource BorderBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
<!-- 统一由 DataGrid 渲染网格线,避免行/列各自画线导致的错位 -->
<Setter Property="GridLinesVisibility" Value="All" />
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource BorderBrush}" />
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource BorderBrush}" />
<Setter Property="RowHeight" Value="26" />
<Setter Property="ColumnHeaderHeight" Value="28" />
<!--
表头边框(Border 绘制)和内容区网格线(DataGrid 内部 Pen 绘制)走的是两套渲染路径,
统一开启像素对齐,避免非整数 DPI 下两者出现 1px 错位
-->
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGrid">
<ControlTemplate.Resources>
<!--<Storyboard x:Key="StoryboardMouseEnter">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HorizontalScrollBar" Storyboard.TargetProperty="Opacity">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value=".8" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="StoryboardMouseLeave">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_VerticalScrollBar" Storyboard.TargetProperty="Opacity">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_HorizontalScrollBar" Storyboard.TargetProperty="Opacity">
<EasingDoubleKeyFrame KeyTime="0:0:.2" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>-->
</ControlTemplate.Resources>
<Border
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}"
SnapsToDevicePixels="True">
<ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
<ScrollViewer.Template>
<ControlTemplate TargetType="ScrollViewer">
<Border Margin="0,0,-1,0" ClipToBounds="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Background="{StaticResource ColumnHeaderBackgroundBrush}">
<Button
Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType=DataGrid}, Converter={StaticResource DoubleMinConverter}}"
Height="auto"
MaxHeight="30"
hc:IconElement.Geometry="{StaticResource AllGeometry}"
Command="{x:Static DataGrid.SelectAllCommand}"
Foreground="{DynamicResource PrimaryBrush}"
IsEnabled="False"
Style="{StaticResource ButtonIcon}"
Visibility="Hidden">
<!--<Button.Visibility>
<MultiBinding Converter="{StaticResource DataGridSelectAllButtonVisibilityConverter}">
<Binding Path="HeadersVisibility" RelativeSource="{RelativeSource AncestorType=DataGrid}" />
<Binding Path="(hc:DataGridAttach.ShowSelectAllButton)" RelativeSource="{RelativeSource AncestorType=DataGrid}" />
</MultiBinding>
</Button.Visibility>-->
</Button>
</Grid>
<DataGridColumnHeadersPresenter
x:Name="PART_ColumnHeadersPresenter"
Grid.Row="0"
Grid.Column="1"
Grid.ColumnSpan="2"
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType=DataGrid}}" />
<ScrollContentPresenter
x:Name="PART_ScrollContentPresenter"
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
CanContentScroll="{TemplateBinding CanContentScroll}" />
<hc:ToggleBlock
Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="2"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsChecked="{Binding HasItems, RelativeSource={RelativeSource AncestorType=DataGrid}, Mode=OneWay}">
<hc:ToggleBlock.UnCheckedContent>
<hc:Empty
Background="{DynamicResource RegionBrush}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
</hc:ToggleBlock.UnCheckedContent>
</hc:ToggleBlock>
<ScrollBar
x:Name="PART_VerticalScrollBar"
Grid.Row="0"
Grid.RowSpan="3"
Grid.Column="2"
Maximum="{TemplateBinding ScrollableHeight}"
Orientation="Vertical"
Style="{StaticResource BaseStyle}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<ScrollBar
x:Name="PART_HorizontalScrollBar"
Grid.Row="2"
Grid.Column="1"
VerticalAlignment="Bottom"
Maximum="{TemplateBinding ScrollableWidth}"
Orientation="Horizontal"
Style="{StaticResource BaseStyle}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
</Border>
<!--<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard Storyboard="{StaticResource StoryboardMouseEnter}" />
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard Storyboard="{StaticResource StoryboardMouseLeave}" />
</EventTrigger>
</ControlTemplate.Triggers>-->
</ControlTemplate>
</ScrollViewer.Template>
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DataGridLinkColumn" TargetType="Hyperlink">
<Setter Property="Foreground" Value="{StaticResource PrimaryBrush}" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=IsSelected}" Value="True">
<Setter Property="Foreground" Value="{StaticResource TextIconBrush}" />
</DataTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="Selector.IsSelectionActive" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}" />
</MultiTrigger>
</Style.Triggers>
</Style>
<!--
Small 行样式:沿用 Rightangle 的模板(不再自画顶部边框),
网格线线统一交由 DataGrid.Custom.Small 的 GridLinesVisibility 处理。
-->
<Style
x:Key="DataGridRowStyle.Rightangle.Small"
BasedOn="{StaticResource DataGridRowStyle.Rightangle}"
TargetType="{x:Type DataGridRow}">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Padding" Value="0,0" />
</Style>
<Style
x:Key="DataGridCellStyle.Custom.Small"
BasedOn="{StaticResource DataGridCellStyle}"
TargetType="DataGridCell">
<Setter Property="Padding" Value="6,3" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="TextBlock.TextAlignment" Value="Right" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Background" Value="#cde6f7" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
<Style
x:Key="DataGridColumnHeaderStyle.Custom"
BasedOn="{StaticResource DataGridColumnHeader.MarginSmall}"
TargetType="DataGridColumnHeader">
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Padding" Value="6,4" />
</Style>
<Style
x:Key="DataGridRowHeaderStyle.Custom"
BasedOn="{StaticResource DataGridRowHeaderStyle}"
TargetType="DataGridRowHeader">
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridRowHeader}">
<hc:SimplePanel>
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
<ContentPresenter
VerticalAlignment="Center"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</StackPanel>
</Border>
<Thumb
Name="PART_TopHeaderGripper"
VerticalAlignment="Top"
Style="{StaticResource RowHeaderGripperStyle}" />
<Thumb
Name="PART_BottomHeaderGripper"
VerticalAlignment="Bottom"
Style="{StaticResource RowHeaderGripperStyle}" />
</hc:SimplePanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- {x:Type DataGrid} -->
<Style
x:Key="DataGrid.Custom.Small"
BasedOn="{StaticResource DataGrid.Custom}"
TargetType="{x:Type DataGrid}">
<!-- 原来是 18,行内容会被挤压;24 能容纳默认字号并留出上下呼吸空间 -->
<Setter Property="RowHeight" Value="24" />
<Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle.Rightangle.Small}" />
<Setter Property="Padding" Value="1" />
<Setter Property="RowHeaderStyle" Value="{StaticResource DataGridRowHeaderStyle.Custom}" />
<Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle.Custom.Small}" />
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeaderStyle.Custom}" />
<Setter Property="ColumnHeaderHeight" Value="24" />
</Style>
<!-- DataGridEnd -->
</ResourceDictionary>