Silverlight Control 属性作为数据绑定源,View-Model 属性作为目标

发布于 2024-09-26 07:30:16 字数 387 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仙女山的月亮 2024-10-03 07:30:16

也许这有效?
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}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文