perf: update combobox style

dev_settings
DESKTOP-3BO4HSG\ksat 2 years ago
parent 11385128bc
commit 96fe851fbe

@ -1,10 +1,5 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--引入字体文件-->
<Style x:Key="IconStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="/STranslate;component/Images/#iconfont"/>
</Style>
<!--Combox-->
<Style TargetType="{x:Type ComboBox}" x:Key="cmbstyle">
<Setter Property="Background" Value="#282c34"/>
@ -23,14 +18,16 @@
CornerRadius="2"
Background="Transparent"
BorderThickness="0">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter>
<ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="5,0,0,0"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Back" Property="Background" Value="#47484c"></Setter>
<Setter TargetName="Back" Property="Background" Value="#47484c"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Back" Property="Background" Value="#47484c"></Setter>
<Setter TargetName="Back" Property="Background" Value="#47484c"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@ -42,7 +39,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Border BorderThickness="0" CornerRadius="5" Width="80" Height="30" Background="{TemplateBinding Background}" >
<Border BorderThickness="0" CornerRadius="5" Width="80" Height="30"
Background="#282c34" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
@ -72,10 +70,10 @@
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#abb2bf"/>
<Setter Property="Background" Value="#282c34"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="#abb2bf"/>
<Setter Property="Background" Value="#282c34"/>
</Trigger>
</Style.Triggers>
</Style>
@ -95,7 +93,7 @@
<ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<TextBlock Foreground="{TemplateBinding Foreground}" x:Name="arrow_tb" Text="&#xe61d;" Style="{StaticResource IconStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<TextBlock Foreground="{TemplateBinding Foreground}" x:Name="arrow_tb" Text="&#xe61d;" Style="{DynamicResource IconStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
@ -150,9 +148,6 @@
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{TemplateBinding ActualWidth}"
SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="2" ShadowDepth="0" Opacity="0.5"/>
</Border.Effect>
<ScrollViewer Margin="4,6,4,6" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" CanContentScroll="True">
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="#282c34"/>
@ -160,11 +155,6 @@
</Border>
</Popup>
</Grid>
<Border.Effect>
<DropShadowEffect ShadowDepth="-1" Opacity="0.3" Color="#FF969696" BlurRadius="2"/>
</Border.Effect>
</Border>
</ControlTemplate>
</Setter.Value>

@ -1,20 +1,14 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--引入字体文件-->
<Style x:Key="IconStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="/STranslate;component/Images/#iconfont"/>
</Style>
<!--Combox-->
<Style TargetType="{x:Type ComboBox}" x:Key="cmbstyle">
<Setter Property="Background" Value="White"/>
<Setter Property="Background" Value="#f6f6f6"/>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<!--ComBoxItem-->
<Style TargetType="ComboBoxItem">
<Setter Property="MinHeight" Value="22"></Setter>
<Setter Property="MinWidth" Value="40"></Setter>
<Setter Property="MinHeight" Value="22"/>
<Setter Property="MinWidth" Value="40"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBoxItem">
@ -22,14 +16,16 @@
CornerRadius="2"
Background="Transparent"
BorderThickness="0">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0"></ContentPresenter>
<ContentPresenter VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="5,0,0,0"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Back" Property="Background" Value="#eaeaea"></Setter>
<Setter TargetName="Back" Property="Background" Value="#eaeaea"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Back" Property="Background" Value="#eaeaea"></Setter>
<Setter TargetName="Back" Property="Background" Value="#eaeaea"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@ -41,7 +37,8 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Border BorderThickness="0" CornerRadius="5" Width="80" Height="30" Background="{TemplateBinding Background}" >
<Border BorderThickness="0" CornerRadius="5" Width="80" Height="30"
Background="#f6f6f6" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
@ -59,7 +56,7 @@
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press">
<ToggleButton.Style >
<Style TargetType="ToggleButton">
<Setter Property="Background" Value="White"/>
<Setter Property="Background" Value="#f6f6f6"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
@ -71,10 +68,10 @@
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White"/>
<Setter Property="Background" Value="#f6f6f6"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="White"/>
<Setter Property="Background" Value="#f6f6f6"/>
</Trigger>
</Style.Triggers>
</Style>
@ -88,13 +85,13 @@
ClickMode="Press">
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="Background" Value="White"/>
<Setter Property="Background" Value="#f6f6f6"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<TextBlock Foreground="{TemplateBinding Foreground}" x:Name="arrow_tb" Text="&#xe61d;" Style="{StaticResource IconStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<TextBlock Foreground="{TemplateBinding Foreground}" x:Name="arrow_tb" Text="&#xe61d;" Style="{DynamicResource IconStyle}" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
@ -149,21 +146,13 @@
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{TemplateBinding ActualWidth}"
SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect Color="Black" BlurRadius="2" ShadowDepth="0" Opacity="0.5"/>
</Border.Effect>
<ScrollViewer Margin="4,6,4,6" MaxHeight="{TemplateBinding MaxDropDownHeight}" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" CanContentScroll="True">
<!-- StackPanel 用于显示子级,方法是将 IsItemsHost 设置为 True -->
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="White"/>
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" Background="#f6f6f6"/>
</ScrollViewer>
</Border>
</Popup>
</Grid>
<Border.Effect>
<DropShadowEffect ShadowDepth="-1" Opacity="0.3" Color="#FF969696" BlurRadius="2"/>
</Border.Effect>
</Border>
</ControlTemplate>
</Setter.Value>

Loading…
Cancel
Save