如何突出显示LongListSelector所选项目 [英] How to Highlight a Selected Item in LongListSelector

查看:157
本文介绍了如何突出显示LongListSelector所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想简单地显示当前选择的项目周围的边框在我LongListSelector。我已经为我的LongListSelector一个ItemTemplate,但我不确定如何,这样只有当前所选的项目包含边框修改边框。

I would like to simply show a border around the currently selected item in my LongListSelector. I have set an ItemTemplate for my LongListSelector, but I am unsure of how to modify the Border so that only the currently selected item contains a border.

MainPage.xaml中

MainPage.xaml

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Key="ItemTemplate">
        <!-- BorderBrush of all items are currently set to PhoneAccentBrush, need only currently selected item! -->
        <Border x:Name="brd" CornerRadius="10" BorderBrush="{StaticResource PhoneAccentBrush}" Width="Auto" BorderThickness="3">
            <Viewbox Width="108" Height="108">
                <Image x:Name="recentImage" Source="{Binding Source}" Margin="6,6" Width="108"/>
            </Viewbox>
            <toolkit:ContextMenuService.ContextMenu>
                <toolkit:ContextMenu x:Name="imgListContextMenu" Background="{StaticResource PhoneChromeBrush}">
                    <toolkit:MenuItem Foreground="{StaticResource PhoneForegroundBrush}" Header="delete" Click="deleteContextMenuItem_Click"/>
                </toolkit:ContextMenu>
            </toolkit:ContextMenuService.ContextMenu>
        </Border>
    </DataTemplate>

</phone:PhoneApplicationPage.Resources>

...

<phone:LongListSelector x:Name="Recent" Margin="0" 
                                    SelectionChanged="recent_SelectionChanged" 
                                    toolkit:TiltEffect.IsTiltEnabled="True"
                                    LayoutMode="Grid" GridCellSize="108,108"
                                    ItemTemplate="{StaticResource ItemTemplate}"
                                    />

目前内的所有项目的 LongListSelector 示的边界。我宁愿在后面的代码来修改这一点,但什么我迄今无法正常工作

Currently all of the items within the LongListSelector show the border. I would prefer to modify this in the code behind, but what I have thus far does not work

MainPage.xaml.cs中

MainPage.xaml.cs

private void recent_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {            
        var item = sender  as LongListSelector
        item.BorderBrush = App.Current.Resources["PhoneAccentBrush"] as SolidColorBrush;
    }



任何想法?

Any ideas?

推荐答案

请参阅此链接,

在WP8的LongListSelector突出显示所选的项目
http://code.msdn.microsoft.com/wpapps/高亮-一个选择项,30ced444

这篇关于如何突出显示LongListSelector所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆