ItemsControl.ItemStringFormat 屬性

定義

取得或設定複合字串,這個字串會指定如何格式化 ItemsControl 中要以字串形式顯示的項目。

public:
 property System::String ^ ItemStringFormat { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public string ItemStringFormat { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ItemStringFormat : string with get, set
Public Property ItemStringFormat As String

屬性值

複合字串,指定如何格式化 ItemsControl 中要以字串形式顯示的項目。

屬性

範例

下列範例會使用 ItemStringFormat 指定 物件清單 DateTime 的格式。

<ListBox xmlns:sys="clr-namespace:System;assembly=mscorlib"
         ItemStringFormat="MMMM d, yyyy">
  <sys:DateTime>2004/3/4</sys:DateTime>
  <sys:DateTime>2004/8/9</sys:DateTime>
  <sys:DateTime>2005/10/14</sys:DateTime>
  <sys:DateTime>2005/4/8</sys:DateTime>
</ListBox>
  
  <!--The results when the default culture is en-US:
      March 4, 2004
      August 9, 2004
      October 14, 2005,
      April 8, 2005-->

備註

ItemStringFormat 可以是預先定義的、複合或自訂字串格式。 如需字串格式的詳細資訊,請參閱 格式化類型。 如果您設定 ItemTemplateItemsControlItemTemplateSelector ,則會 ItemStringFormat 忽略 屬性。

適用於