Silverlight Control 属性作为数据绑定源,View-Model 属性作为目标
我在 Silverlight 控件上有一个 ViewModel 想要绑定到的属性。 ViewModel 需要告知属性的更改,而不是相反的
语法,例如
<MyControl ViewPort="{Binding VMProperty}"/>
声明 ViewPort 作为目标,在本例中 ViewPort 是数据源。我知道我可以将其设为双向绑定,但是当我只想要一种方式但在另一个方向时,这似乎是错误的。
此外,我不想将控件上的属性设置为 DependencyProperty,因为我不希望该属性可设置,并且我不相信 Silverlight 支持只读依赖属性。
是否有其他设置绑定的方法?
蒂亚·
帕特·朗
I have a property on a Silverlight control that a ViewModel wants to bind to. The ViewModel need to told of changes to the property NOT the other way around
Syntax like
<MyControl ViewPort="{Binding VMProperty}"/>
Declares ViewPort as the Target, in this instance ViewPort is the source of the data. I know I could make it TwoWay binding but that just seems wrong when i simply want one way but in the other direction.
Besides I do not want to make the property on the control a DependencyProperty because I do not want that property settable and I do not beleive that Silverlight supports read only dependency properties.
Is there a different way of setting up the Binding?
TIA
Pat Long
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这有效?
http://forums.silverlight.net/forums/p/141042/315359 .aspx#315359
{Binding ElementName=TextBox1,Path=Text,Mode=TwoWay,UpdateSourceTrigger=Explicit}
Maybe this works?
http://forums.silverlight.net/forums/p/141042/315359.aspx#315359
{Binding ElementName=TextBox1, Path=Text, Mode=TwoWay ,UpdateSourceTrigger=Explicit}