ComboBox.PlaceholderText 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置控件中显示的文本,直到用户操作或其他操作更改值为止。
public:
property Platform::String ^ PlaceholderText { Platform::String ^ get(); void set(Platform::String ^ value); };
winrt::hstring PlaceholderText();
void PlaceholderText(winrt::hstring value);
public string PlaceholderText { get; set; }
var string = comboBox.placeholderText;
comboBox.placeholderText = string;
Public Property PlaceholderText As String
<ComboBox PlaceholderText="placeholderString"/>
属性值
未选择值时控件中显示的文本。 默认值为空字符串("")。
示例
下面介绍如何将占位符文本添加到 ComboBox。
<ComboBox Header="Colors" PlaceholderText="Pick a color">
<x:String>Blue</x:String>
<x:String>Green</x:String>
<x:String>Red</x:String>
<x:String>Yellow</x:String>
</ComboBox>
注解
当 SelectedIndex 为 -1 且 SelectedItem 为 null 时,将显示占位符文本。 (这两个属性保持同步。) 选择项目后,用户无法显示占位符文本。 但是,可以编程方式将 SelectedIndex 设置为 -1 或 SelectedItem 设置为 null ,以再次显示占位符文本。
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈