【问题标题】:semantic zoom grouped data binding and accessing individual items语义缩放分组数据绑定和访问单个项目
【发布时间】:2012-09-28 11:43:00
【问题描述】:

我正在将数据绑定到我的 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>

任何帮助都会很棒,而且我对此很陌生,尽可能简单:) 谢谢

【问题讨论】:

    标签: c# xaml data-binding windows-8 windows-runtime


    【解决方案1】:

    首先,您的 Group.Key 应该在 GridView.GroupStyle 中,并且您的项目应该在 GridView.ItemTemplate 下。有了它,您将能够访问组项目本身。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多