2013-03-20 35 views
0

我正在開發一個c#/ xaml metro應用程序。如何更改metro應用程序中列表框中某個特定listboxitem的背景顏色?

我有一個列表框,其中取決於一個特定的條件,我只想改變一個listboxitem背景顏色。

這是怎麼了我曾嘗試: -

if (lststudents != null) 
{ 
    foreach (StudentClass obj in lststudents) 
    { 
     if (obj.stutype == "Red House") 
     { 
///I am unable to typecast to listboxitem, since it is of type student class 
ListBoxItem lstbxbitem = (obj)ListBoxItem; 
/// 
      lstbxbitem.Background = new SolidColorBrush(Colors.Red); 
     } 
    } 
} 
lstbxbStudents.ItemsSource = lststudents ; 

請注意: - 我要改變只取決於一些特定條件的一些listboxitems的背景色。

請讓我知道我可以做到這一點?

什麼是各種替代品?

在此先感謝。

+0

你有沒有完成上述要求的任務,如果是的話,你能告訴我怎麼你做到了??因爲我也陷入了同樣的問題 – Aju 2013-12-05 05:52:54

回答

相關問題