Binding eco handles to a WPF combobox
Take a deep breath; comboboxes are tricky bastards.
The combobox is set up like this:
<ComboBox Name="ComboWithClassesForNesting" DisplayMemberPath="Name" SelectedValuePath="self" SelectedValue="{Binding Path=SelectedClass}"></ComboBox>
The ItemSource of the combo is set in code to this:
_classeseh=new ExpressionHandle();
_classeseh.RootHandle=rhSpan;
_classeseh.AddSelfColumn=true;
_classeseh.Expression="Class.allinstances->orderby(x|x.Name)";
The itemsource will be a list of renederedtuples.
The ComboBox context will also be a renderedtuple.
The gotcha is that the renderedtuple from one handle is not equal to a renderedtuple from another handle, so the comparison that will be done when the combo tries to find the current value in the possible values (ItemSource values) must be treated as the objects they are.
SelectedValuePath = The path expression used on each item in the itemSource in order to be a pickable value -> a model object; most likely "self". Make sure you have AddSelfColumn==true in your expressionhandle . Leaving the SelectedValuePath empty will make the binding try to match a renderedtuple from the ItemsSource with the result from SelectedValue and that will NEVER work.
SelectedValue = The property that contains the current value set in the datacontext; this is most likely a singlelink member; you will need to add this to the ExpressionHandle as Column (not nested), give it a name like SelectedXXX or something to distinguish it from the default nesting of XXX if you have it.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home