views:

118

answers:

1

I've been exploring WPF and XAML for a while now, but have hit a slight stumbling block revolving around binding to a method.

My situation is:

There is a ComboBox bound to a DataTable. There is a ListBox bound to the return value of a method (GetDates) via an ObjectDataProvider. One of the input parameters of the method GetDates is an Id stored in the ComboBox/DataTable.

How can I bind a MethodParameter in the ObjectDataProvider to a particular value of the SelectedItem of a ComboBox (in this case, the SelectedItem is of type DataRowView)? Alternatively, am I missing a better way of solving this problem?

I can see ways out of it by using the code-behind, but I'd like to know if there's a more XAML-y solution. It's always useful to pick up little tips and tricks, even if it turns out not to be the best fix to this problem.

A: 

http://msdn.microsoft.com/en-us/library/system.windows.data.objectdataprovider.methodparameters.aspx

This seems to describe what I need - although it's actually trying to answer a different problem.

(Aside: Is it just me or is that example on MSDN trying to do too much all at once?)

By binding the ItemsSource of the ComboBox to a DataTable, and the SelectedItem of the ComboBox to a MethodParameter (with a converter to extract the value I need from the DataRowView), the ObjectDataProvider will have the parameter it needs.

It would probably be easier to read/follow/maintain if I just hooked into the ComboBox.SelectionChanged event.

pete the pagan-gerbil