C# 语义缩放分组数据绑定和访问单个项
我将数据绑定到缩放语义缩放,如下所示:C# 语义缩放分组数据绑定和访问单个项,c#,xaml,data-binding,windows-8,windows-runtime,C#,Xaml,Data Binding,Windows 8,Windows Runtime,我将数据绑定到缩放语义缩放,如下所示: var result = from title in _allTitles group title by title._titleSubject into grp orderby grp.Key select grp; groupedTitlesSource.Source = result; (semanticZoom.ZoomedOutView as ListViewBase).ItemsSource = groupedTitlesSource.
var result = from title in _allTitles group title by title._titleSubject into grp orderby grp.Key select grp;
groupedTitlesSource.Source = result;
(semanticZoom.ZoomedOutView as ListViewBase).ItemsSource = groupedTitlesSource.View.CollectionGroups;
我使用Group.Key访问密钥,但我也想访问组中的第一项,最简单的方法是什么?下面是ZoomeOutView的我的Xaml:
<SemanticZoom.ZoomedOutView>
<GridView x:Name="zoomedOutGridView" HorizontalAlignment="Center">
<GridView.ItemTemplate>
<DataTemplate>
<Grid Width="210" Height="140" Background="#CC196CFF">
<TextBlock
Text="{Binding Group.Key}"
FontFamily="Segoe UI Light"
FontSize="24"
Foreground="White"
VerticalAlignment="Top"/>
<!-- Also want to access the first item in the group here -->
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
</SemanticZoom.ZoomedOutView>
任何帮助都会很好,我对这一点非常陌生,尽可能简单:
首先感谢您的组。键应位于GridView.GroupStyle中,您的项目应位于GridView.ItemTemplate下。这样,您就可以访问组项目本身