Home > database >  How to add style for every listbox.Item in code behind?
How to add style for every listbox.Item in code behind?

Time:11-20

i am trying to add different styles for every listbox.Item in my project. Can anyone help me about that?

`



            foreach (var item in orderList)
            {
                var itm = new ListBoxItem();

                if (item.CustomOrder)
                {
                    itm.Content = item;
                    itm.Style = customOrderStyle;
                    listbox.Items.Add(itm);


                }
                else
                {
                    itm.Content = item;
                    itm.Style = newOrderStyle;
                    listbox.Items.Add(itm);


                }
            }

`

My content doesnt shown like this.

I know that i am adding Listbox item to the listbox, that's why content is doesnt shown. I try some different things too but still dont know how to solve it.

CodePudding user response:

Check the enter image description here

  • Related