无法从XAML和Setter绑定类型IList的DependencyProperty [英] Cannot bind DependencyProperty of type IList from both XAML and Setter

查看:87
本文介绍了无法从XAML和Setter绑定类型IList的DependencyProperty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从这里执行代码:

Can not bind ObservableCollection to list dp from xaml

我发现如果我有几个实例的控件在同一页面中,IList收到了给所有控件的所有值。
我在线阅读,为了解决这个问题,必须写下:

I found out that if I had several instances of the control in the same page, the IList recieved all the values given to all the controls. I read online that in order to solve this, one must write:

SetValue(...) in the constructor.

这使得上述链接中显示的Setter不起作用。
(我猜是因为这次我们需要IList是静态的,而不是每个实例)。

This causes the Setter that is shown in above link not to work. (I guess that is because this time we need the IList to be static and not per-instance).

请帮助!
谢谢

Please help! Thanks

推荐答案

使用SetCurrentValue而不是SetValue。

Use SetCurrentValue instead of SetValue.

这篇关于无法从XAML和Setter绑定类型IList的DependencyProperty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆