Hey guys,
I am currently attempting to use an object data provider to return the colour that I would like to use as a background for each listbox item, with the colour dependent on that listbox items index.
Basically the parameters passed to the object is the original colour and the listboxitem index, and it will return a colour that is lighter based on what index it is... here is the code i have currently for the object 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 am aware that you cannot do a direct bind because it is not a dependency object and does not conform to the rules for binding, and that you must set it directly... however, i'm not sure where in my listbox item xaml I am supposed to bind back.
Furthermore, upon a long search for the answer to this, I have only found examples where people only change the parameters based on things such as what someone enters into a textbox using this method:-
{Binding Source={StaticResource RankColour},
Path=MethodParameters[1],
BindsDirectlyToSource=True,
UpdateSourceTrigger=PropertyChanged}
I want it to be bound to the listbox index, so not sure what property to put that into.
Second question: The listbox item does have a label who's content is bound to the listbox item index, however, how can I use the above binding source technique to bind the content, when i always want to bind it to the index?
Thanks for your help in advance! =)