2011-06-06 22 views
5

嗨,我是窗口手機7的新手,我有問題的應用樣式在列表框中替換行顏色在Windows Phone 7中。請幫助我。如何在列表框中應用交替行樣式在手機7

+1

您應該發佈一些您有故障代碼,並解釋實際問題。 [看到這裏提出了很好的問題](http://tinyurl.com/so-hints)。 – pickypg 2011-06-06 05:00:59

+0

@Vijay Chavda:你可以提供你用於在windows phone app中爲行應用替代顏色的代碼嗎? – nkchandra 2012-12-06 11:35:11

回答

4

雖然WPF有一個支持這個屬性的ALternationCount屬性,但Web版本和WP7都沒有。在Silverlight中創建這種效果的最簡單方法是通過值轉換器設置項目的背景顏色。請參閱以下主題:

Alternating background colors for ListBox rows

+1

http://forums.silverlight.net/forums/t/14345.aspx – 2011-06-06 05:45:46

+0

嗨每個人我都從下面的鏈接得到的解決方案 http://forums.silverlight.net/forums/t/14345.aspx – 2011-06-06 05:46:50

+0

酷 - 你有沒有把上面的回答作爲答案? – ColinE 2011-06-06 05:49:48

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; 
    } 
相關問題