大家好,我是XAML概念的新手,我知道我需要一些CollectionViewSource的概念,我有一个带有GridView的WinRT应用程序,我想按职业对每个项目进行分组,我创建了一个ModelView如何翻译成我在谷歌搜索的collectionView源代码,但这里没有解决方案去几部分代码:
<Page.Resources>
<DataTemplate x:Key="MyDataTemplate">
<Border >
<Grid Background="DodgerBlue" Height="150" Width="200" Margin="0,-7,-7,0" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False">
<StackPanel VerticalAlignment="Bottom">
<StackPanel.Background>
<SolidColorBrush Color="Black" Opacity=".25"/>
</StackPanel.Background>
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Profession}"/>
<TextBlock Text="{Binding Age}"/>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<VariableSizedWrapGrid x:Name="gridviewVariableSized" MaximumRowsOrColumns="4" Orientation="Vertical" />
</ItemsPanelTemplate>
</Page.Resources>
<Page.DataContext>
<ModelView:PeopleCollection/>
</Page.DataContext>发布于 2013-02-19 17:52:21
在您的ViewModel调用中获取CollectionViewSource
var groupable = CollectionViewSource.GetDefaultView(this.PeopleCollection);(假设Peoplecollection是一个ObservableCollection或类似的东西。一旦你有了它,你就可以使用
groupable.GroupDescriptions.Add(new PropertyGroupDescription("Country"));https://stackoverflow.com/questions/14954214
复制相似问题