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 の場合、プレースホルダー テキストが表示されます。 (これら 2 つのプロパティは同期された状態に保たれます。アイテムが選択されると、ユーザーはプレースホルダー テキストを表示できません。 ただし、 プログラムによって SelectedIndex を -1 に設定するか 、SelectedItemnull に設定すると、プレースホルダー テキストが再び表示されます。

適用対象