开发者

Can MethodParameters in an ObjectDataProvider be databound to other controls?

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开发者_JAVA百科 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜