我正在将数据绑定到我的 ZoomedOut 语义缩放,如下所示:
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访问密钥,但我也想访问组中的第一项,最简单的方法是什么? 我的Xaml在下面为ZoomedOutView:
<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>
任何帮助都会很棒,我对这个尽可能简单的一切都很陌生:)谢谢
首先,您的 Group.Key 应该位于 GridView.GroupStyle 中,您的项目应该位于 GridView.ItemTemplate 下。这样,您将能够访问组项目本身。