ComboBox.PlaceholderText 屬性

定義

取得或設定控制項中顯示的文字,直到使用者動作或其他作業變更值為止。

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"/>

屬性值

String

Platform::String

winrt::hstring

未選取任何值時,控制項中顯示的文字。 預設為空字串 ("")。

範例

以下說明如何將預留位置文字新增至 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 且 SelectedItemNull時,會顯示預留位置文字。 (這兩個屬性會保持同步。) 使用者一旦選取專案之後,就無法顯示預留位置文字。 不過,您可以程式設計方式將 SelectedIndex 設定為 -1 或 SelectedItem 設定為 null ,以再次顯示預留位置文字。

適用於