Order items horizontal in XAML GridView (Win8 / Metro)

前端 未结 3 829
孤独总比滥情好
孤独总比滥情好 2021-02-10 22:21

how can i sort the items of GridView horizontal in the XAML? Sadly i found no method to achieve this. The Keyword \"Orientation\" is not available. Here is my current GridView:<

相关标签:
3条回答
  • 2021-02-10 22:35

    Just set the orientation of the ItemsWrapGrid:

    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <ItemsWrapGrid Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>
    
    0 讨论(0)
  • 2021-02-10 22:36

    Sorry, I have to take issue with your comment that this cannot be done with a VariableSizedWrapGrid. It most certainly can:

    <GridView>
        <GridView.ItemsPanel>
            <ItemsPanelTemplate>
                <VariableSizedWrapGrid Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </GridView.ItemsPanel>
        <x:String>One</x:String>
        <x:String>Two</x:String>
        <x:String>Three</x:String>
        <x:String>Four</x:String>
    </GridView>
    

    And I have to take issue that VariableSizedWrapGrid cannot be used for creating items through ItemsSource. It most certainly can. WrapGrid and VariableSizedWrapGrid are fundamentally identical. WrapGrid is slightly lighter weight since it does not support Column and Row spanning.

    0 讨论(0)
  • 2021-02-10 22:59

    Add an ItemsPanelTemplate to control how the items are arranged, for instance,

    <GridView.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapGrid Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </GridView.ItemsPanel>
    
    0 讨论(0)
提交回复
热议问题