0

I'm trying to achieve custom selection of selected item in listview. In default, selected item has border around it. I wanted to add CornerRadius to it but couldn't. So I decided to add my own border in ItemTemplate and make it visible for the currently selected item only.

Here's my ItemTemplate for Listview:

 <ListView.ItemTemplate>
     <DataTemplate>
         <Grid>
             <Border Height="73"
                     Width="73">
                 <Image Stretch="UniformToFill"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Center"
                        Source="{Binding ImgPath}">
                 </Image>
             </Border>
             <Border x:Name="CornerRadiusBorder"
                     Height="78"
                     Width="77"
                     BorderBrush="Blue"
                     BorderThickness="3"
                     CornerRadius="3">
             </Border>
         </Grid>
    </DataTemplate>
</ListView.ItemTemplate>

I want to make CornerRadiusBorder visible only for selected item.

Muhammad Hassan
  • 1,037
  • 1
  • 8
  • 22
  • I don't know how well this will work in WinRT, but check [this](http://stackoverflow.com/questions/146269/change-wpf-datatemplate-for-listbox-item-if-selected) out. The idea is to apply your rounded border as an `ItemContainerStyle`, instead of within the `ItemTemplate`. – Mike Eason Jun 10 '15 at 13:21
  • What you need has already answered here : http://stackoverflow.com/questions/12150683/styling-selecteditem-in-listview-in-metro-app-xaml – Burak Kaan Köse Jun 10 '15 at 17:32
  • @BurakKaanKöse I've already implemented it. That solution only allows selection thickness and color change. – Muhammad Hassan Jun 11 '15 at 06:44
  • Border element has CornerRadius property inside that template , you can easily edit that though. – Burak Kaan Köse Jun 11 '15 at 07:01
  • @MikeEason didn't work for WinRT. Style.Triggers not available. – Muhammad Hassan Jun 12 '15 at 06:36
  • @BurakKaanKöse Please paste the code. I've already played with template but no use. – Muhammad Hassan Jun 12 '15 at 06:55

0 Answers0