如何在Windows Phone 7中的列表框中应用交替行样式

5

你好,我是新手使用Windows Phone 7,我在应用样式到窗口手机7中的列表框的交替行颜色时遇到了问题,请帮助我。


1
你应该发布一些你遇到问题的代码,并解释实际的问题。点击此处了解如何提出好问题 - pickypg
@Vijay Chavda:你能提供一下你在Windows Phone应用中使用的交替行颜色代码吗? - nkchandra
2个回答

4
虽然WPF具有支持此功能的ALternationCount属性,但Silverlight(包括Web版和WP7)不支持。在Silverlight中创建此效果的最简单方法是通过值转换器设置项目的背景颜色。请参阅以下线程:Alternating background colors for ListBox rows

大家好,我从以下链接中找到了解决方案: http://forums.silverlight.net/forums/t/14345.aspx - Vijay Chavda
酷 - 你是否已经给上面的回答点赞/标记为答案了? - ColinE
2
你回答中的链接已经失效/无效。能否提供正确的链接? - nkchandra
只是提醒一下,整个解决方案存在缺陷,因为您需要考虑这个http://stackoverflow.com/questions/10532881/alternating-row-background-color-for-listbox-rows-in-window-phone-7 - GONeale

1

private void Item_LayoutRoot_Loaded(object sender, RoutedEventArgs e)
    {

        StackPanel ItemRef = sender as StackPanel;      // get the reference to the control
        SolidColorBrush brush1 = new SolidColorBrush(Color.FromArgb(0,0,0,0));      //base colour
        SolidColorBrush brush2 = new SolidColorBrush(Color.FromArgb(255,255,0,0));  //alternate colour

        if (_useAlternate)
            ItemRef.Background = brush1;
        else
            ItemRef.Background = brush2;

        _useAlternate = !_useAlternate;
    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接