locked
Set number of rows from code (GridView) RRS feed

  • Question

  • Hi developers!

    I have a question how to set the number of rows from the code (C#)

    I have following xaml code:

                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <VariableSizedWrapGrid  x:Name="LogoGrid" Orientation="Vertical" Margin="0,0,80,0" ItemWidth="180" ItemHeight="160" MaximumRowsOrColumns="3"/>
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>  

    I want to let users to set number of rows on the Settings page,

    my GridView:

    <local:VariableSizeGridView

    />


    class VariableSizeGridView: GridView
        {       
            protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item)
            {           
                base.PrepareContainerForItemOverride(element, item);        
            }
        }

    Is it possible? And is it possilbe to change number of rows at runtime?

    Sunday, September 15, 2013 2:10 PM

All replies

  • you can use the visualtreehelper. But the VSWG is generated for each group. Also can use the loaded event or maybe size changed (its what i often use)

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Sunday, September 15, 2013 5:55 PM
  • you can use the visualtreehelper. But the VSWG is generated for each group. Also can use the loaded event or maybe size changed (its what i often use)

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#


    could you please write a sample of code?
    Monday, September 16, 2013 9:28 AM
  • Is it possible to change number of rows by changing templates?

                   <GroupStyle.Panel>                           
                        <ItemsPanelTemplate>
                            <VariableSizedWrapGrid Background="Red"  Orientation="Vertical" Margin="0,0,40,0" />
                        </ItemsPanelTemplate>
                    </GroupStyle.Panel>

    for example to create templates in the Page resources, use GroupStyleSelector?

    • Marked as answer by Andev Thursday, September 19, 2013 3:36 PM
    • Unmarked as answer by Andev Thursday, September 19, 2013 3:36 PM
    Wednesday, September 18, 2013 6:20 PM