如何在 WP8 上的 LongListSelector 中突出显示所选项目? [英] How to highlight a selected item in the LongListSelector on WP8?

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

问题描述

如何在 Windows Phone 8 上的新 LongListSelector 中突出显示所选项目?如果我点击列表中的一个条目,实际上什么也没发生.我的列表只包含一个将通过 TextBlock 显示的简单字符串.但我想突出显示用户的选择.

How is it possible to highlight the selected item in the new LongListSelector on Windows Phone 8? Actually nothing happend if I tapped one entry of the list. My list only contains a simple string which will be displayed through a TextBlock. But I want to highlight the selection of the user.

谢谢.

推荐答案

在我的例子中,我在 LongListSelectorItemDataTemplate 中使用了一个 RadioButtonControl代码>来实现这一点.您将在左边框处有一个选中或未选中的标志.

In my case I used a RadioButtonControl in the DataTemplate of the LongListSelectorItem to achieve this. You will have a checked oder unchecked sign at the left border.

无论如何,为所有单选按钮设置相同的组很重要,因此选择仅代表一个条目.

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

Content 或您的 RadioButton 中,您可以将 TextBlock 绑定到 String.

Inside the Contentor your RadioButton you can put the TextBlock bound to the String.

我目前不在家,但如果这不能解决您的问题,我在家时会为您提供一些代码;)

Im currently not at home, but if this wont solve your problem, I'll provide you some code when I'm at home ;)

给你:

<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>

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

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