为什么附加属性设置和获取静态方法不叫在XAML? [英] Why attached property Set and Get static methods are not called in XAML?

查看:147
本文介绍了为什么附加属性设置和获取静态方法不叫在XAML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的附加属性一些SetXXX和的getXXX静态方法设置断点。在XAML中,我已经赋值的附加属性。不过,我期待设置或获取静态方法被调用,但事实并非如此。附加属性按预期工作,如果我打电话一些SetXXX和的getXXX在code的方法,然后它的预期。

I have set break points on my attached properties SetXXX and GetXXX static methods. In Xaml, I have assigned values to the attached property. However, I was expecting the Set or Get static methods to be called but they are not. The attached property works as expected and if I call SetXXX and GetXXX methods in code, then it works are expected.

为什么不叫方法在XAML时设置?

Why are the methods not called when set from Xaml?

JD。

推荐答案

作为<一个href="http://stackoverflow.com/questions/2568860/why-attached-property-set-and-get-static-methods-are-not-called-in-xaml/2568868#2568868">JaredPar解释,当您使用XAML中,则getXXX / SetXXX方法不叫。

As JaredPar explained, when you use XAML, the GetXXX/SetXXX methods are not called.

我想补充一点,虽然:

如果您需要跟踪在code改变附加属性,你应该使用的元数据。您可以设置一个回调在元数据中火,当属性发生变化,并在code跟踪。

If you need to track changes to the Attached Property in code, you should use the Metadata. You can set a callback in the metadata to fire when the property changes, and track it in your code.

这篇关于为什么附加属性设置和获取静态方法不叫在XAML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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