2025-07-16 12:19

This commit is contained in:
wang-yin1
2025-07-16 12:20:02 +08:00
parent ca823a9294
commit 25d7fc3330
13 changed files with 801 additions and 305 deletions

View File

@@ -1,45 +1,55 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="#FFACACAC"/>
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060"/>
<SolidColorBrush x:Key="TextBox.Static.Background" Color="#FFFFFFFF" />
<SolidColorBrush x:Key="ComboBox.Static.Border" Color="#FFACACAC" />
<SolidColorBrush x:Key="ComboBox.Static.Glyph" Color="#FF606060" />
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Focusable" Value="false" />
<Setter Property="ClickMode" Value="Press" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="templateRoot"
Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="#DDDDDD"
CornerRadius="3">
<Border x:Name="splitBorder" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
SnapsToDevicePixels="true" Margin="0" HorizontalAlignment="Right"
BorderThickness="1" BorderBrush="Transparent">
<Path Data="M0 0 4 4 8 0" Stroke="#CCC" StrokeThickness="1"
VerticalAlignment="Center" Name="path"
Width="8" HorizontalAlignment="Center"
RenderTransformOrigin="0.5,0.5"/>
<Border
x:Name="templateRoot"
Background="{TemplateBinding Background}"
BorderBrush="#DDDDDD"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3">
<Border
x:Name="splitBorder"
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
Margin="0"
HorizontalAlignment="Right"
BorderBrush="Transparent"
BorderThickness="1"
SnapsToDevicePixels="true">
<Path
Name="path"
Width="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0 0 4 4 8 0"
RenderTransformOrigin="0.5,0.5"
Stroke="#CCC"
StrokeThickness="1" />
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="BorderBrush" TargetName="templateRoot" Value="green"/>
<Setter TargetName="templateRoot" Property="BorderBrush" Value="green" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="BorderBrush" TargetName="templateRoot" Value="green"/>
<Setter TargetName="templateRoot" Property="BorderBrush" Value="green" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="path" Property="RenderTransform">
<Setter.Value>
<RotateTransform Angle="180"/>
<RotateTransform Angle="180" />
</Setter.Value>
</Setter>
</Trigger>
@@ -52,48 +62,73 @@
<ControlTemplate x:Key="ComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
</Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
Placement="Bottom" VerticalOffset="1">
<Border x:Name="dropDownBorder"
BorderBrush="#DDD"
BorderThickness="1" CornerRadius="5"
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
<ScrollViewer x:Name="DropDownScrollViewer"
Background="Transparent" BorderThickness="0">
<Popup
x:Name="PART_Popup"
Grid.ColumnSpan="2"
Margin="1"
AllowsTransparency="true"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
VerticalOffset="1">
<Border
x:Name="dropDownBorder"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"
BorderBrush="#DDD"
BorderThickness="1"
CornerRadius="5">
<ScrollViewer
x:Name="DropDownScrollViewer"
Background="Transparent"
BorderThickness="0">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
<Canvas x:Name="canvas" HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
<Rectangle x:Name="opaqueRect" Fill="{Binding Background, ElementName=dropDownBorder}"
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
RadiusX="7" RadiusY="7"/>
<Canvas
x:Name="canvas"
Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle
x:Name="opaqueRect"
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Fill="{Binding Background, ElementName=dropDownBorder}"
RadiusX="7"
RadiusY="7" />
</Canvas>
<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Margin="3"/>
<ItemsPresenter
x:Name="ItemsPresenter"
Margin="3"
KeyboardNavigation.DirectionalNavigation="Contained"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</Popup>
<ToggleButton x:Name="toggleButton" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="White" Grid.ColumnSpan="2"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ComboBoxToggleButton}"/>
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsHitTestVisible="false" Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<ToggleButton
x:Name="toggleButton"
Grid.ColumnSpan="2"
Background="White"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ComboBoxToggleButton}" />
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
IsHitTestVisible="false"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<!--<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
@@ -101,54 +136,59 @@
<Setter Property="Background" TargetName="shadow" Value="#71000000"/>
</Trigger>-->
<Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="dropDownBorder" Value="95"/>
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsGrouping" Value="true"/>
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
<Condition Property="IsGrouping" Value="true" />
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</MultiTrigger>
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
<Trigger SourceName="DropDownScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter TargetName="opaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
<Setter TargetName="opaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="#333"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="Padding" Value="6,3,5,3"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template" Value="{StaticResource ComboBoxTemplate}"/>
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="#333" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Padding" Value="6,3,5,3" />
<Setter Property="ScrollViewer.CanContentScroll" Value="true" />
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template" Value="{StaticResource ComboBoxTemplate}" />
</Style>
<Style TargetType="ComboBoxItem">
<Setter Property="Height" Value="30"/>
<Setter Property="Height" Value="30" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
<Border Background="White" BorderBrush="Transparent" BorderThickness="1" CornerRadius="3"
Margin="1" Name="border">
<ContentPresenter VerticalAlignment="Center" Margin="3"/>
<Border
Name="border"
Margin="1"
Background="White"
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="3">
<ContentPresenter Margin="3" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#111F71E5"/>
<Setter TargetName="border" Property="BorderBrush" Value="#551F71E5"/>
<Setter TargetName="border" Property="Background" Value="#111F71E5" />
<Setter TargetName="border" Property="BorderBrush" Value="#551F71E5" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="border" Property="Background" Value="#1F71E5"/>
<Setter TargetName="border" Property="BorderBrush" Value="#1F71E5"/>
<Setter Property="Foreground" Value="White"/>
<Setter TargetName="border" Property="Background" Value="#1F71E5" />
<Setter TargetName="border" Property="BorderBrush" Value="#1F71E5" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>