ItemsControl.ItemsPanel 屬性

定義

取得或設定樣板,這個樣板會定義控制項目配置的面板。

public:
 property ItemsPanelTemplate ^ ItemsPanel { ItemsPanelTemplate ^ get(); void set(ItemsPanelTemplate ^ value); };
ItemsPanelTemplate ItemsPanel();

void ItemsPanel(ItemsPanelTemplate value);
public ItemsPanelTemplate ItemsPanel { get; set; }
var itemsPanelTemplate = itemsControl.itemsPanel;
itemsControl.itemsPanel = itemsPanelTemplate;
Public Property ItemsPanel As ItemsPanelTemplate
<itemsControl>
  <itemsControl.ItemsPanel>
    singlePanelTemplate
  </itemsControl.ItemsPanel>
</itemsControl>
- or -
<itemsControl ItemsPanel="resourceReferenceToPanelTemplate"/>

屬性值

ItemsPanelTemplate,定義要用於專案版面配置的面板。 ItemsControl 的預設值是指定 StackPanel 的 ItemsPanelTemplate

範例

將 ListView 中使用的預設面板取代為 ItemsStackPanel ,其 Orientation 已變更為 Horizontal。

<ListView>
    <x:String>Hello</x:String>
    <x:String>World</x:String>

    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsStackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ListView>

備註

注意

ComboBox 使用 CarouselPanel 作為其 ItemsPanel。 不支援使用不同的面板做為 ComboBox 的 ItemsPanel,而且可能會導致不想要的行為。

適用於