C# wpf --- This is a "continuation" of c-sharpcorner.com/forums/how-do-i-programmically-change-the-foreground-color-in-a-listbox.
Jayraj Chhaya, I have this xaml code:
<ListBox x:Name="gLBxOriginalCities" Margin="5,0,5,10" Foreground="#000000" MouseDoubleClick="gLBxOriginalCities_MouseDoubleClick"> </ListBox>
and modified the xaml.cs code:
int iCount = liststX.Count(); for (int ii = 0; ii < iCount; ii++) { if (liststX[ii].Contains("blue")) LBx.Items.Add(liststX[ii], System.Drawing.Color.Blue); else if (liststX[ii].Contains("red")) LBx.Items.Add(liststX[ii], System.Drawing.Color.Red); else if (liststX[ii].Contains("green")) LBx.Items.Add(liststX[ii], System.Drawing.Color.Green); }
Results in
No overload for method 'Add' takes 2 arguments
---
Sarthak Varshney, My mistake for not clarifying that I am using wpf. There are many other ListBoxes, CheckBoxes, etc. in the xaml file.
Not sure how to proceed with using the xaml code.
How do I programmically change the Foreground color in a ListBox?