WPF GridView: 确定已选中的项

3

我尝试从Windows应用程序中突出显示Bridview中的选定项。

更确切地说:

    <GridView
        x:Name="itemGridView"
        AutomationProperties.AutomationId="ItemsGridView"
        AutomationProperties.Name="Items"
        TabIndex="1"
        Grid.RowSpan="2"
        Padding="116,136,116,46" 
        SelectionMode="None"
        IsSwipeEnabled="false"
        IsItemClickEnabled="True"
        ItemClick="openRessource"
        ItemsSource="{Binding Source={StaticResource itemsViewSource}}">
        <GridView.ItemTemplate>
            <DataTemplate>
                <Grid HorizontalAlignment="Left" Width="200" Height="250"  Holding="openHoldMenu">
                    <Border Background="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}">
                        <Image Source="{Binding icon}" Stretch="None"/>
                    </Border>
                    <Image Source="{Binding downloaded}" Width="30" Height="30" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Top"/>
                    <StackPanel VerticalAlignment="Bottom" Background="{ThemeResource ListViewItemOverlayBackgroundThemeBrush}">
                        <TextBlock Text="{Binding Mode=OneWay}" Foreground="{ThemeResource ListViewItemOverlayForegroundThemeBrush}" Style="{StaticResource BaseTextBlockStyle}" Height="60" Margin="15,0,15,0" FontWeight="SemiBold"/>
                        <TextBlock Text="{Binding description, Mode=OneWay}" Foreground="{ThemeResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Style="{StaticResource BaseTextBlockStyle}" TextWrapping="NoWrap" Margin="15,0,15,10" FontSize="12"/>
                    </StackPanel>
                </Grid>
            </DataTemplate>
        </GridView.ItemTemplate>
    </GridView>

这是我的XAML,非常简单,我只有一个Holding事件,在页面上弹出菜单。
我的问题是我想知道哪个项目被选中了,以便在其周围创建边框,让用户知道哪个项目已被选中。
我可以轻松访问我的列表中的绑定项,但无法获取所选的网格元素。
如果有人知道如何做到这一点,那将不胜感激。 谢谢!
1个回答

0

感谢您的快速回答。 不幸的是,在Windows应用程序中,样式触发器不可用。 - Pierre P.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接