tags:

views:

84

answers:

1

Is it possible to swap out the entire View of a ListView in Xaml using datatemplates? Looking for a way to allow the user to change how they view the data in a ListView and I'm hoping to stay within Xaml. I have found how to change the template of a single column/cell.

A bit more detail of what I'm trying to accomplish: I'd like to have two different GridViews, each showing different columns (except the first one). And I'd like to allow the user to select which view to use via radio buttons.

Part of this is coming from my attempt to learn WPF so I may be asking for something that can't be done, or I may be making it more difficult than I need to make it.

Thanks, David

+3  A: 

The ListView.View property is a dependency property, so you should be able to bind it quite easily:

<ListView View="{Binding CurrentView}"/>

So all you need to do is assign the appropriate GridView to the CurrentView property, and it should just work.

HTH, Kent

Kent Boogaart
Thanks Kent. Definitely got me on the right track. I've got my solution working, just need to figure out if it's the best way.
dfmartinjr
I'd make the two views in XAML and use a trigger to switch between them. IMO it's the best and easiest way to do it.
Bryan Anderson
+1 nice and simple, beautiful
bendewey