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

ItemsControl 的子類型可能會使用不同的預設 ItemsPanelTemplates。 例如, ListView預設會使用 ItemsStackPanel。 使用不同的類型可能會導致非預期的行為;例如,使用一般 StackPanel 做為 ListView 的 ItemsPanel 可以在拖放期間回歸朗讀程式列為。

範例

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

<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,而且可能會導致不想要的行為。

適用於