How to apply an alternative line style to the list in the phone window 7

Hi, I am new to Windows 7, I have a problem for applying style to the alternate color of the lines in the list in the phone window 7. Please help me.

+5
source share
2 answers

While WPF has a feature ALternationCountthat supports this, Silverlight, both the web version and WP7, does not. The easiest way to create this effect in Silverlight is to set the background color of your element using a value converter. See the next section:

Alternative background colors for ListBox strings

+4
source

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;
    }
+1
source

All Articles