fix: 修复ComboBox控件的PlaceholderForeground属性失效 (#543)

* fix: 修复ComboBox控件的PlaceholderForeground属性失效

* Update src/Semi.Avalonia/Themes/Dark/ComboBox.axaml

Co-authored-by: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>

* Update src/Semi.Avalonia/Controls/ComboBox.axaml

Co-authored-by: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>

* Update src/Semi.Avalonia/Themes/Light/ComboBox.axaml

Co-authored-by: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>

* add: 对比色主题添加ComboBoxSelectorPlaceHolderForeground资源

* Revert "add: 对比色主题添加ComboBoxSelectorPlaceHolderForeground资源"

This reverts commit ba526e2cf9.

* add: 对比色主题添加ComboBoxSelectorPlaceHolderForeground资源

* Update src/Semi.Avalonia/Themes/HighContrast/ComboBox.axaml

Co-authored-by: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>

---------

Co-authored-by: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
This commit is contained in:
snail1519
2025-02-26 10:45:24 +08:00
committed by GitHub
parent d906a7754c
commit 3761a0a3fb
4 changed files with 6 additions and 3 deletions

View File

@@ -12,7 +12,7 @@
<ComboBoxItem>BBB</ComboBoxItem>
<ComboBoxItem>CCC</ComboBoxItem>
</ComboBox>
<ComboBox Width="100" PlaceholderText="Select">
<ComboBox Width="100" PlaceholderText="Select" PlaceholderForeground="Red">
<ComboBoxItem>AAA</ComboBoxItem>
<ComboBoxItem>BBB</ComboBoxItem>
<ComboBoxItem>CCC</ComboBoxItem>
@@ -44,6 +44,7 @@
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxDefaultHeight}" />
<Setter Property="PlaceholderForeground" Value="{DynamicResource ComboBoxSelectorPlaceHolderForeground}"/>
<Setter Property="Template">
<ControlTemplate TargetType="ComboBox">
<DataValidationErrors>
@@ -65,9 +66,8 @@
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextTrimming="CharacterEllipsis"
Foreground="{TemplateBinding Foreground}"
Foreground="{TemplateBinding PlaceholderForeground}"
IsVisible="{TemplateBinding SelectionBoxItem,Converter={x:Static ObjectConverters.IsNull}}"
Opacity="0.3"
Text="{TemplateBinding PlaceholderText}" />
<ContentPresenter
Name="ContentPresenter"

View File

@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StaticResource x:Key="ComboBoxSelectorBackground" ResourceKey="SemiColorFill0" />
<StaticResource x:Key="ComboBoxSelectorPlaceHolderForeground" ResourceKey="SemiColorText2" />
<StaticResource x:Key="ComboBoxSelectorPointeroverBackground" ResourceKey="SemiColorFill1" />
<StaticResource x:Key="ComboBoxSelectorFocusBackground" ResourceKey="SemiColorFill1" />
<StaticResource x:Key="ComboBoxSelectorPressedBackground" ResourceKey="SemiColorFill2" />

View File

@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StaticResource x:Key="ComboBoxSelectorBackground" ResourceKey="SemiColorWindow" />
<StaticResource x:Key="ComboBoxSelectorPlaceHolderForeground" ResourceKey="SemiColorGrayText" />
<StaticResource x:Key="ComboBoxSelectorPointeroverBackground" ResourceKey="SemiColorHighlightText" />
<StaticResource x:Key="ComboBoxSelectorFocusBackground" ResourceKey="SemiColorWindow" />
<StaticResource x:Key="ComboBoxSelectorPressedBackground" ResourceKey="SemiColorHighlightText" />

View File

@@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StaticResource x:Key="ComboBoxSelectorBackground" ResourceKey="SemiColorFill0" />
<StaticResource x:Key="ComboBoxSelectorPlaceHolderForeground" ResourceKey="SemiColorText2" />
<StaticResource x:Key="ComboBoxSelectorPointeroverBackground" ResourceKey="SemiColorFill1" />
<StaticResource x:Key="ComboBoxSelectorFocusBackground" ResourceKey="SemiColorFill1" />
<StaticResource x:Key="ComboBoxSelectorPressedBackground" ResourceKey="SemiColorFill2" />