c# – TextBlock.GetBindingExpression返回NULL

前端之家收集整理的这篇文章主要介绍了c# – TextBlock.GetBindingExpression返回NULL前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
以下是为我返回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中的注释.

原文链接:https://www.f2er.com/csharp/97662.html

猜你在找的C#相关文章