locked
How to set number of shown items under each group in GroupedItemsPage

    Question

  • Hi all!
    I'm developing an app using Visual Studio 2013, as a start I used Grid App template provided by Microsoft. I have a problem with showing items under each group in GroupedItemsPage. In the DataModel I have many groups and many items under each, so I want to limit shown items to 5.

    I did some research and found that it could be done by using MaximumRowsOrColumns, but it didnt work for me. Also I tried to use VariableSizedWrapGrid instead of ItemsWrapGrid, but anyway it's not working...

    All search results are related to Windows 8, and it is no working for me.

    Please help

    Monday, September 01, 2014 12:36 AM

Answers

  • Hi Kumarkhan,

    MaximumRowsOrColumns is not the solution for your question, it will limit the maximum rows or column for the template, but not the binding source.

    I would suggest you use a Converter here, for instance you have a array contains 10 items, by using a converter you can cut the number to 5, and binding that 5 items to the template. For more information please ref to: Converting data for display in controls and  Converter property.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 01, 2014 7:29 AM
    Moderator
  • Items were handled by this code, to limit number to 5

    var sampleDataGroups = await SampleDataSource.GetGroupsAsync();
                foreach (SampleDataGroup group in sampleDataGroups){
                    int count = group.Items.Count() - 1;
                    int x=5;
                    for (int i = 5; i <= count; i++)
                    {
                            group.Items.RemoveAt(x);
                    }
                }

    Tuesday, September 02, 2014 1:54 PM

All replies

  • Hi Kumarkhan,

    MaximumRowsOrColumns is not the solution for your question, it will limit the maximum rows or column for the template, but not the binding source.

    I would suggest you use a Converter here, for instance you have a array contains 10 items, by using a converter you can cut the number to 5, and binding that 5 items to the template. For more information please ref to: Converting data for display in controls and  Converter property.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 01, 2014 7:29 AM
    Moderator
  • Hi James,

    Thanks a lot! I also was thinking about this method, so basically i need to limit my items inside each group only for particular page... Is it correct? I'll mark your post as answer after applying it to my project.

    Monday, September 01, 2014 1:09 PM
  • Items were handled by this code, to limit number to 5

    var sampleDataGroups = await SampleDataSource.GetGroupsAsync();
                foreach (SampleDataGroup group in sampleDataGroups){
                    int count = group.Items.Count() - 1;
                    int x=5;
                    for (int i = 5; i <= count; i++)
                    {
                            group.Items.RemoveAt(x);
                    }
                }

    Tuesday, September 02, 2014 1:54 PM