How to highlight selected item in LongListSelector on WP8?

How can I highlight a selected item in the new LongListSelector on Windows Phone 8? In fact, nothing happened if I clicked one entry in the list. My list contains only a simple string that will be displayed through a TextBlock. But I want to highlight the user's choice.

Thanks.

+8
c # xaml windows-phone-8
source share
1 answer

In my case, I used RadioButton Control in a DataTemplate for LongListSelectorItem to achieve this. On the left border you will have a marked or unchecked sign.

In any case, it is important that you set the same group for all Radiobuttons, so the selection only represents one record.

Inside Content or your RadioButton you can bind a TextBlock to a String .

I'm currently not at home, but if this does not solve your problem, I will give you the code when I'm at home;)

Here you go:

 <LongListSelector.ItemTemplate> <DataTemplate> <ContentControl HorizontalAlignment="Stretch" HorizontalContentAlignment="Left"> <RadioButton HorizontalAlignment="Stretch" Margin="0,0,0,0" GroupName="A" Background="Black" > <StackPanel toolkit:TiltEffect.IsTiltEnabled="True"> <TextBlock Text="{Binding Path=XXX}" TextWrapping="Wrap" Foreground="Black" Style="{StaticResource PhoneTextExtraLargeStyle}"/> <TextBlock Text="{Binding Path=XXXX}" TextWrapping="Wrap" Foreground="Black" Margin="14,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"/> </StackPanel> </RadioButton> </ContentControl> </DataTemplate> </LongListSelector.ItemTemplate> 
+10
source share

All Articles