ContentControl.ContentStringFormat プロパティ
定義
public:
property System::String ^ ContentStringFormat { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string ContentStringFormat { get; set; }
member this.ContentStringFormat : string with get, set
Public Property ContentStringFormat As String
プロパティ値
Content プロパティが文字列として表示される場合に、その書式を指定する複合文字列。A composite string that specifies how to format the Content property if it is displayed as a string.
- 属性
例
次の例では、 DateTime Style ContentStringFormat Label ContentControlでプロパティを設定し、を継承する2つのオブジェクトにを適用することによって、オブジェクトの書式を指定しています。StyleThe following example specifies the format of DateTime objects by setting the ContentStringFormat property in a Style and applying the Style to two Label objects, which inherit from ContentControl.
<StackPanel
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<StackPanel.Resources>
<Style x:Key="DateLabel" TargetType="Label">
<Setter Property="ContentStringFormat" Value="dddd – d - MMMM"/>
</Style>
</StackPanel.Resources>
<!--The results when the default culture is en-US
is March 4, 2005.-->
<Label Style="{StaticResource DateLabel}">
<sys:DateTime>2004/3/4 13:6:55</sys:DateTime>
</Label>
<Label Style="{StaticResource DateLabel}">
<x:Static Member="sys:DateTime.Now"/>
</Label>
</StackPanel>
注釈
ContentStringFormatは、定義済み、複合、またはカスタムの文字列形式にすることができます。ContentStringFormat can be a predefined, composite, or custom string format. 文字列形式の詳細については、「型の書式設定」を参照してください。For more information about string formats, see Formatting Types. ContentTemplate ContentTemplateSelectorのプロパティまたはプロパティを設定した場合、プロパティは無視されます。ContentControl ContentStringFormatIf you set the ContentTemplate or ContentTemplateSelector property of a ContentControl, the ContentStringFormat property is ignored.