开发者

How to retrieve a specific dataBinding from MultiBindingExpression?

In my application I retrieve binding from one object and assign it to another. And some objects has MultiBinding instead. And I want to retrieve a specific binding. How do I do that?

For non multi-bindings I use the following code:

Label lbl = (Label)sender;
BindingExpression bindingExpression = lbl.GetBindingExpression.(Label.ContentProperty);
Binding parentBinding = bindingExpression.ParentBinding;
path = parentBinding.XPath.ToString();
label.SetBinding(Label.Conten开发者_JAVA技巧tProperty, parentBinding);


I have figured it out. I couldn't get binding directly from label, but I was able to use BindingOperations.GetMultiBindingExpression static method to retrieve MultiBindingExpression and then getting the right Binding.

Here is code for that:

MultiBindingExpression multiBindingExpression = BindingOperations.GetMultiBindingExpression(lbl, Label.ContentProperty);
Binding parentBinding = ((BindingExpression)multiBindingExpression.BindingExpressions[1]).ParentBinding;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜