Hi I am trying to add color to bg of a listview item dynamically while runtime but I get the following exception.
Unable to cast object of type 'RootObject.Controls.ListItem' to type 'System.Windows.Controls.ListViewItem'.
My requirement is to check a condition while clicking a button and if the process is success change the bg to green else red. Here is my WPF code
<ListView x:Name="ListView" SelectionChanged="List_SelectionChanged" MouseDoubleClick="List_MouseDoubleClick" SelectionMode="Single"/>
And here is my code behind,
if(RootVal.sendResult == true)
{
foreach (ListViewItem item1 in ListView.Items)
{
item1.Background = System.Windows.Media.Brushes.Green;
}
}