Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:21:42+00:00 2026-06-12T17:21:42+00:00

How do I write the code that flows items in a GridView (XAML-Win8) group,

  • 0

How do I write the code that flows items in a GridView (XAML-Win8) group, according to the below illustration?

I currently have a custom TemplateSelector that selects a different (larger) template for the first item, but the flow as specified here:

<GroupStyle.Panel>
    <ItemsPanelTemplate>
        <q42:WrapPanel Orientation="Horizontal" Width="440" Margin="0,0,80,0"/>
        <!-- also tried VariableSizedWrapGrid -->
    </ItemsPanelTemplate>
</GroupStyle.Panel>

Wraps items 1 through 3 similarly, but then places item 4 at item 6’s position, without filling out items 4 nor 5.

Question becomes; how do I write code that acts similar to css:

.item  { display: inline-block; }
.item1 { float: left; }

, which would make the items flow like I want?

What I'd like the flow to look like

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:21:45+00:00Added an answer on June 12, 2026 at 5:21 pm

    Andreas Hammar linked me to a working solution:

    What it looks like

    using System.Collections.Generic;
    using Application1.Data;
    using Windows.Foundation;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    
    namespace Application1
    {
        public class MyGridView : GridView
        {
            int _rowVal;
            int _colVal;
            readonly List<Size> _sequence;
    
            public MyGridView()
            {
                _sequence = new List<Size>
                    {
                        LayoutSizes.PrimaryItem,
                        LayoutSizes.SecondarySmallItem,
                        LayoutSizes.SecondarySmallItem,
                        LayoutSizes.OtherSmallItem,
                        LayoutSizes.OtherSmallItem, // 5 
                        LayoutSizes.OtherSmallItem,
                        LayoutSizes.SecondaryTallItem, // 7
                        LayoutSizes.OtherSmallItem,
                        LayoutSizes.SecondarySmallItem, // 9
                        LayoutSizes.OtherSmallItem,
                        LayoutSizes.SecondarySmallItem, // 11
                        LayoutSizes.SecondarySmallItem,
                        LayoutSizes.OtherSmallItem,
                        LayoutSizes.OtherSmallItem
                    };
            }
    
            protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
            {
                base.PrepareContainerForItemOverride(element, item);
                var dataItem = item as SampleDataItem;
                var index = -1;
    
                if (dataItem != null)
                {
                    index = dataItem.Group.Items.IndexOf(dataItem);
                }
    
                if (index >= 0 && index < _sequence.Count)
                {
                    _colVal = (int) _sequence[index].Width;
                    _rowVal = (int) _sequence[index].Height;
                }
                else
                {
                    _colVal = (int) LayoutSizes.OtherSmallItem.Width;
                    _rowVal = (int) LayoutSizes.OtherSmallItem.Height;
                }
    
                VariableSizedWrapGrid.SetRowSpan(element as UIElement, _rowVal);
                VariableSizedWrapGrid.SetColumnSpan(element as UIElement, _colVal);
            }
        }
    
        public static class LayoutSizes
        {
            public static Size PrimaryItem = new Size(6, 2);
            public static Size SecondarySmallItem = new Size(3, 1);
            public static Size SecondaryTallItem = new Size(2, 2);
            public static Size OtherSmallItem = new Size(2, 1);
        }
    }
    

        <local:MyGridView.ItemsPanel>
            <ItemsPanelTemplate>                        
                <VirtualizingStackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </local:MyGridView.ItemsPanel>
        <local:MyGridView.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <Grid Margin="1,0,0,6">
                            <Button
                                AutomationProperties.Name="Group Title"
                                Content="{Binding Title}"
                                Click="Header_Click"
                                Style="{StaticResource TextButtonStyle}"/>
                        </Grid>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
                <GroupStyle.Panel>
                    <ItemsPanelTemplate>
                        <VariableSizedWrapGrid ItemWidth="80" ItemHeight="160" Orientation="Vertical" Margin="0,0,80,0" MaximumRowsOrColumns="3"/>
                    </ItemsPanelTemplate>
                </GroupStyle.Panel>
            </GroupStyle>
        </local:MyGridView.GroupStyle>
    </local:MyGridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I have to write code that alternates between doing things and checking for
I have some code I need to write a test for that connects to
I m trying write code that after reset set up rrpmax as 3000. It
I'm trying to write code that will load an image from a resource, and
I've been trying to write code that loads a .png file, attaches hotspot information,
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common
I need to write some code that would loop though all rows of a
I'm trying to write a code that adds a class to a div for
I am trying to write some code that will generate accurate .proto files from
I'm trying to write a code that could print something like this -xv -xvv

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.