c# - Change Foreground item of ListView -


i want change foreground of item on listview of uwp. using:

int i_deleterow = listview1.selectedindex; var item = listview1.items[i_deleterow] listviewitem;  if (item != null) {     item.foreground = new solidcolorbrush(colors.red); } 

but code item null. appreciated.

you need use itemcontainergenerator.containerfromindex. returns dependencyobject can cast listboxitem , use listboxitem's properties foreground:

listviewitem item = (listviewitem)(listview1.itemcontainergenerator.containerfromindex(listview1.selectedindex)); if (item != null) {     item.foreground = new solidcolorbrush(colors.red); } 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

c# - Json.Net Serialize String from URI -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -