以下是为我返回NULL,任何想法为什么?
MultiBinding collectionRange = new MultiBinding(); collectionRange.Bindings.Add(new Binding("CurrentPosition") { Source = View }); collectionRange.Bindings.Add(new Binding("Count") { Source = View }); collectionRange.StringFormat = "{0} of {1}"; tbFooter.SetBinding(TextBlock.TextProperty,collectionRange); var x = tbFooter.GetBindingExpression(TextBlock.TextProperty);
MultiBinding很好 – 属性是有效的,它在UI上呈现..我似乎无法抓取绑定表达式(x始终为NULL)
我使用这种方法错了吗?
解决方法
This method is really just a convenience wrapper around the
BindingOperations.GetBindingExpression method. GetBindingExpression
passes the current instance and the dp parameter to
BindingOperations.GetBindingExpression.If your binding is a MultiBinding,use
BindingOperations.GetMultiBinding.
请参阅“备注”部分和“示例”部分here中的注释.