How to change Listbox item color from selected Item(object)?

RollRoll

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

Clemens

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Change background color of selected item in listbox

From Dev

how to change the background of the selected item in a listbox?

From Dev

how to change the background of the selected item in a listbox?

From Dev

How to set the Selected Item's text color in Html.Listbox

From Dev

How to change the Foreground Color of ListView Selected Item

From Dev

How to change the Foreground Color of ListView Selected Item

From Dev

How to change selected listview item color

From Dev

Getting selected item from a listbox

From Dev

How to change the background color of a ListBox Item when hovering?

From Dev

how to change listbox item color c# based on its index

From Dev

How to change the background color of a ListBox Item when hovering?

From Dev

WPF XAML listbox selected item border color

From Dev

Change color of ListBox Item when Clicked on this Item

From Dev

How to get selected item of a listbox within a listbox

From Java

How to show the numeric position from a selected item in a listbox in a label

From Dev

How to remove selected item from ListBox in windwos phone 8.1 Silverlight

From Dev

How to show data from selected item in listbox wpf using mvvm?

From Dev

How to get an image to display in Picturbox from a Listbox selected item

From Dev

How to get particular property from item selected in ListBox

From Dev

How can i remove the blue color wraping the selected item in listBox1 when clicking on item?

From Dev

NavigationView(Change Color of Selected Item)

From Dev

Change background color of selected usercontrol in listbox

From Dev

Change ListBox Item Background color programmatically

From Dev

How do I change the color of a selected item on a ListView?

From Dev

How to change color of icon of selected item in material drawer?

From Dev

Android ListView. How to change background color of manually selected item

From Dev

Android - how to change the background color of the selected item in a dropdown

From Dev

How can I change the color of the selected item in a menu?

From Dev

How to change color of the selected ListView item [WP8.1]

Related Related

  1. 1

    Change background color of selected item in listbox

  2. 2

    how to change the background of the selected item in a listbox?

  3. 3

    how to change the background of the selected item in a listbox?

  4. 4

    How to set the Selected Item's text color in Html.Listbox

  5. 5

    How to change the Foreground Color of ListView Selected Item

  6. 6

    How to change the Foreground Color of ListView Selected Item

  7. 7

    How to change selected listview item color

  8. 8

    Getting selected item from a listbox

  9. 9

    How to change the background color of a ListBox Item when hovering?

  10. 10

    how to change listbox item color c# based on its index

  11. 11

    How to change the background color of a ListBox Item when hovering?

  12. 12

    WPF XAML listbox selected item border color

  13. 13

    Change color of ListBox Item when Clicked on this Item

  14. 14

    How to get selected item of a listbox within a listbox

  15. 15

    How to show the numeric position from a selected item in a listbox in a label

  16. 16

    How to remove selected item from ListBox in windwos phone 8.1 Silverlight

  17. 17

    How to show data from selected item in listbox wpf using mvvm?

  18. 18

    How to get an image to display in Picturbox from a Listbox selected item

  19. 19

    How to get particular property from item selected in ListBox

  20. 20

    How can i remove the blue color wraping the selected item in listBox1 when clicking on item?

  21. 21

    NavigationView(Change Color of Selected Item)

  22. 22

    Change background color of selected usercontrol in listbox

  23. 23

    Change ListBox Item Background color programmatically

  24. 24

    How do I change the color of a selected item on a ListView?

  25. 25

    How to change color of icon of selected item in material drawer?

  26. 26

    Android ListView. How to change background color of manually selected item

  27. 27

    Android - how to change the background color of the selected item in a dropdown

  28. 28

    How can I change the color of the selected item in a menu?

  29. 29

    How to change color of the selected ListView item [WP8.1]

HotTag

Archive