gpt4 book ai didi

c# - TextBlock.GetBindingExpression 返回 NULL

转载 作者:太空狗 更新时间:2023-10-29 19:58:35 25 4
gpt4 key购买 nike

以下为我返回 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 上呈现..我似乎无法获取绑定(bind)表达式(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 .

关于c# - TextBlock.GetBindingExpression 返回 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12033021/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com