附属财产问题
我有一个附加属性,名称为“翻译”。我这样设置属性:
<Label Target="{Binding ElementName=UserName}"
Content="User Name"
Extensions.Translate="true"/>
我在属性更改事件处理程序中获取目标值,它为空。但我在 XAML 中设置了它。为什么它是空的?
谢谢。
I have a attached property which name is "Translate". I set the property like this:
<Label Target="{Binding ElementName=UserName}"
Content="User Name"
Extensions.Translate="true"/>
I get the Target value in the property changed event handler and it is null. But I set it in the XAML. Why is it null?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
绑定直到加载 UI 过程的后期才会发生,因此在应用本地值“true”时,绑定尚未被评估。您需要推迟对目标值的检查,直到更新绑定之后。这应该可以让您开始使用 Translate PropertyChanged 处理程序:
Binding doesn't occur until later in the process of loading the UI so at the point that your local value of "true" is being applied the Binding has yet to be evaluated. You need to postpone the check of the Target value until after the Binding has been updated. This should get you started in the Translate PropertyChanged handler: