Jeremy Edwards
Jeremy Edwards

Reputation: 14740

Windows RT: Snapped mode Change GridView to ListView

When my app is snapped displaying a GridView isn't the best way to present the information. I want to present it in a ListView instead. I also want to change the item template as well.

I currently have a UserControl that accepts the DataContext as the item template so I can simply create a new view and use that instead and it should work. So I'm basically looking to swap local:NormalDetailView with local:SnappedDetailView

Originally I thought about having both the ListView and GridView in there at the same time and adjusting the visibility based on snapped mode. But I had doubts about the performance about this technique.

Lastly, this is a LayoutAwarePage so I do have all that XAML stuff at the bottom about VisualStateManager.VisualStateGroups etc.

    <GridView x:Name="GalleryGridView"ItemsSource="{Binding ListOfItems}">
        <GridView.ItemTemplate>
            <DataTemplate>
                <local:NormalDetailView VerticalAlignment="Center" Width="250" Height="250"  DataContext="{Binding}"/>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>

Upvotes: 1

Views: 462

Answers (1)

chue x
chue x

Reputation: 18803

The performance is just fine if you use both a gridview and a listview, and adjust visibility depending on view state. This is exactly what the "split-application" template in Visual Studio does.

Just generate an app based on this template and take a look at ItemsPage.xaml and ItemsPage.xaml.cs. The other templates may also do this, but I haven't used them so I don't know for sure.

Upvotes: 3

Related Questions