KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm writing a Windows 8 Metro app. I'm trying to draw a GridView with three Groups. I want one of those groups to layout their items differently than the others. I've used Selectors before in WPF, so I thought that'd be a good route. So I tried the GroupStyleSelector and I found this example on MSDN : public class ListGroupStyleSelector : GroupStyleSelector { protected override GroupStyle SelectGroupStyleCore(object group, uint level) { return (GroupStyle)App.Current.Resources["listViewGroupStyle"]; } } So I altered/expanded on it from something that would suit me: CS: public class ExampleListGroupStyleSelector : GroupStyleSelector { public ExampleListGroupStyleSelector () { OneBigItemGroupStyle = null; NormalGroupStyle = null; } public GroupStyle OneBigItemGroupStyle { get; set; } public GroupStyle NormalGroupStyle { get; set; } protected override GroupStyle SelectGroupStyleCore( object group, uint level ) { // a method that tries to grab an enum off the bound data object var exampleListType= GetExampleListType( group ); if ( exampleListType== ExampleListType.A) { return OneBigItemGroupStyle; } if ( exampleListType== ExampleListType.B|| exampleListType== ExampleListType.B) { return NormalGroupStyle; } throw new ArgumentException( "Unexpected group type" ); } } XAML: <Page.Resources> <ExampleListGroupStyleSelector x:Key="ExampleListGroupStyleSelector" OneBigItemGroupStyle="{StaticResource OneBigGroupStyle}" NormalGroupStyle="{StaticResource NormalGroupStyle}" /> </Page.Resources> <GridView ItemsSource="{Binding Source={StaticResource exampleListsViewSource}}" GroupStyleSelector="{StaticResource ExampleListGroupStyleSelector}"> <Gr
Tags (comma-separated)
Save Edits
Cancel