【发布时间】:2021-02-15 23:21:05
【问题描述】:
我想在我的演示 UWP 应用中更改 ComboBox 占位符颜色。所以我尝试创建静态资源:
<UserControl.Resources>
<Style x:Key="ComboBoxStyle" TargetType="ComboBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<ContentControl x:Name="PlaceholderTextContentPresenter"
Content="{TemplateBinding PlaceholderText}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
使用:
<ComboBox Grid.Row="1" Foreground="White" HorizontalAlignment="Stretch" Background="Transparent"
PlaceholderText="Выбор оператора" Style="{StaticResource ComboBoxStyle}">
<x:String>iPhone 11</x:String>
<x:String>iPhone 12</x:String>
<x:String>Xiaomi Red Mi</x:String>
<x:String>Samsung Galaxy 10</x:String>
<ComboBox.Resources>
<Style TargetType="ContentControl">
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="15" />
</Style>
</ComboBox.Resources>
</ComboBox>
占位符中的前景已正确更改,但 ComboBox 消失了。如何更改 ComboBox 占位符前景?
【问题讨论】:
标签: xaml uwp combobox uwp-xaml