Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */
posts - 159, comments - 0, trackbacks - 0

My Links


Your host

This is me! This space is about Microsoft® .NET® and Microsoft® Visual Basic development. Enjoy! :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.

Microsoft MVP

My MVP Profile

I'm a VB!

Watch my interview in Seattle

My new book on VB 2015!

Pre-order VB 2015 Unleashed Pre-order my new book "Visual Basic 2015 Unleashed". Click for more info!

My new book on LightSwitch!

Visual Studio LightSwitch Unleashed My book "Visual Studio LightSwitch Unleashed" is available. Click the cover!

Your visits

Follow me on Twitter!

CodePlex download Download my open-source projects from CodePlex!

Article Categories


Post Categories

.NET Framework


Help Authoring

Microsoft & MSDN

Setup & Deployment

Visual Basic 2005/2008/2010

WinRT: ho to solve if ListView and GridView lose their way

In a Windows Store App I've been working on, I had to face a particular problem. It is a problem that can randomly occur with the GridView and ListView controls and it probably depends on the DataTemplate you use.

Consider the following GridView:

                <GridView Name="MyView" ItemsSource="{Binding}" Margin="0,15,0,0" HorizontalAlignment="Left">
                            <!-- custom DataTemplate -->

In this page I have this object; then I navigate to a secondary page. From the secondary page, I navigate back to the page where I have the GridView.

As a result, instead of showing items horizontally (as required), the control shows them vertically losing the original orientation.

I searched on the Internet but the only one taling about this problem is a guy at Microsoft, who provides a possible solution in this blog post. Unfortunately that solution did not work for me, so what I did is changing the template of the panel for the view. In this case I used a StackPanel. This works well for me because I have a few items and I don't need virtualization. In code:

                            <StackPanel Orientation="Horizontal"/>

In this way, everything worked correctly. In conclusion, if you face this problem remember to work on the ItemsPanelTemplate.


Print | posted on giovedì 14 marzo 2013 11:14 | Filed Under [ Windows 8 & WinRT ]


No comments posted yet.

Post Comment

Please add 1 and 2 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET