Pass index of list item as parameter to objectdataprovider

I'm currently trying to use the object's data provider to return the color that I would like to use as the background for each list item, with a color that depends on this index of the list items.

Basically, the parameters passed to the object are the source color and the listboxitem index, and it returns a color that is easier based on the index that is ... here is the code that I currently have for the object's data provider:

    <ObjectDataProvider ObjectType="{x:Type local:cUserProfiles}"
              MethodName="GetRankColour" x:Key="RankColour">
        <ObjectDataProvider.MethodParameters>
            <Color> {ORIGINAL_COLOUR}<Color/>
            <system:Int16>{LISTBOXITEM INDEX}</system:Int16>
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>

I know that you cannot directly link, because it is not an object of dependencies and does not comply with the binding rules, and that you should install it directly ... however, I am not sure where in my listbox item xaml I have to link back.

In addition, during a long search for the answer to this question, I found only examples when people change only parameters based on such things as the fact that someone enters the text field using this method: -

{Binding Source={StaticResource RankColour},   
                 Path=MethodParameters[1],  
                 BindsDirectlyToSource=True,  
                 UpdateSourceTrigger=PropertyChanged}

I want it to be associated with the listbox index, so I'm not sure which property to insert it.

Second question: There is a label in the list item whose content is bound to the index of the list item, however, how can I use the above binding source method to bind the content when I always want to bind it to the index?

Thanks for your help in advance! =)

+3
source share
1 answer

, ? , , , . , - , , .

, ( , , , lol). ? ?

0

Source: https://habr.com/ru/post/1767738/


All Articles