从父 silverlight 页面的文本框到另一个本地 silverlight 用户控件的文本框之间的两种方式绑定
我已经使用 DependencyProperty 将值从 silverlight 页面的文本框传递到位于同一页面的外部 silverlight 用户控件,并且工作正常。
但问题是我无法以反向方式绑定页面中的文本框。即当我需要在父页面中更改其用户控件的文本框文本时进行更改。
XAML:
<TextBox x:Name="TextDataCollectionAccounts" Width="200" Height="25" VerticalAlignment="Top"></TextBox>
<Local:CalControl x:Name="RCal" DateRange="{Binding ElementName=TextDataCollectionAccounts, Path=Text, Mode=TwoWay}" Visibility="Collapsed"/>
如何将“TextDataCollectionAccounts”(在 silverlight 页面中)与“Local:CalControl”的文本框绑定?
I have used DependencyProperty to pass value from textbox at silverlight page to external silverlight user control located in same page and that works fine.
But the problem is I could not bind the Textbox in page in reverse way. i.e. when i need to have changes in parent page when its usercontrol's textbox text is changed.
The XAML:
<TextBox x:Name="TextDataCollectionAccounts" Width="200" Height="25" VerticalAlignment="Top"></TextBox>
<Local:CalControl x:Name="RCal" DateRange="{Binding ElementName=TextDataCollectionAccounts, Path=Text, Mode=TwoWay}" Visibility="Collapsed"/>
How to bind "TextDataCollectionAccounts"(in silverlight page) with Textbox of "Local:CalControl"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上永远不要尝试绑定到用户控件的内部工作。将其视为第三方控件并公开属性和事件。
如果你需要一个具体的例子,尽管问,但听起来你已经快到了并且了解你的 DP。
Basically never try to bind to the inner workings of a user control. Treat it like it was a third-party control and expose properties and events.
If you need a specific example, just ask, but it sounds like you are almost there and know your DPs.