私は c#/xaml メトロ アプリケーションを開発しています。
私はリストボックスを持っています.1つの特定の条件に応じて、リストボックスアイテムの背景色を1つだけ変更したいです。
これは私が試した方法です:-
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 ;
注意してください:-特定の条件に応じて、一部のリストボックス項目のみの背景色を変更したい。
どうすればこれを達成できるか教えてください??
さまざまな代替手段は何ですか??
前もって感謝します。