繁体   English   中英

在WP8.1中显示ComboBox的PlaceholderText颜色

[英]Show PlaceholderText Color of ComboBox in WP8.1

我想问你该怎么做才能在白色背景网格上显示ComboBox的placeholderText。

 <Grid Background="White">
    <ComboBox Name="CityCombobox"   BorderThickness="0"  Grid.Column="1" PlaceholderText="Select Item">
        <ComboBoxItem>Chandigarh</ComboBoxItem>
        <ComboBoxItem>Delhi</ComboBoxItem>
        <ComboBoxItem>Sirsa</ComboBoxItem>
    </ComboBox>
</Grid>

好吧,显然是因为您将背景设为白色,并且占位符颜色也为白色(当电话背景色为黑色时),所以您看不到占位符。 您可以做的就是不要将背景色设置为白色,因为Windows Phone的默认设置将其设置为黑色或白色,并确保占位符颜色可见。

否则,您将需要覆盖占位符的颜色。 您可以通过两种方式执行此操作。

  1. 全局:这将覆盖整个应用程序中占位符的所有颜色。 您可以在app.xaml中这样做

<ResourceDictionary.ThemeDictionaries> <ResourceDictionary x:Key="Default"> <SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush" Color="#ff000000" /> </ResourceDictionary> </ResourceDictionary.ThemeDictionaries>

  1. 覆盖对象的样式。 当您在xaml中添加元素时。 在设计器中右键单击它。 在那里您可以选择复制样式。 将此放置在文档中。 找到TextBoxPlaceholderTextThemeBrushTextBoxPlaceholderTextThemeBrush提供值。 然后给你的XAML元素这种特殊的风格

试试这个

            <ComboBox SelectionChanged="City_SelectionChanged" Name="CityCombobox" RequestedTheme="Light" BorderThickness="0" Tapped="CitySelection_Tapped" Grid.Column="1" PlaceholderText="Select City">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding City.city}" Style="{StaticResource PageTextStyle}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

此处请求的主题设置了用于控制的浅色主题,即使在白色背景下也显示占位符文本。 希望能帮助到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM