How to Highlight a Selected Item in LongListSelector

后端 未结 1 1033
时光取名叫无心
时光取名叫无心 2021-01-20 04:47

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

相关标签:
1条回答
  • 2021-01-20 05:11

    When you access the selected item, you should access it as a border and not as a LongListSelector because that's how you show each item, while the LongListSelector is the container. You also forgot a semi-colon on the 3rd row, I've added it for you.

    Your new code would be:

    private void recent_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {            
        var item = sender as Border;
        item.BorderBrush = App.Current
                              .Resources["PhoneAccentBrush"] as SolidColorBrush;
    }
    
    0 讨论(0)
提交回复
热议问题