I have the following code and I hope to accomplish to change Color from Listbox item associated to that object in items:
foreach (var item in lbMine.Items)
{
MyClass current = (MyClass)item;
if (current.ID == someParamSentID)
{
//How to change listbox color based on 'item'?
}
}
I'm looking for a solution that I don't have to change the xaml.
thanks
You may get the ListBoxItem that contains the current item by calling the ItemContainerGenerator.ContainerFromItem
method:
if (current.ID == someParamSentID)
{
var lbItem = (ListBoxItem)lbMine.ItemContainerGenerator.ContainerFromItem(current);
...
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments