我已经在我的附加属性一些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。
推荐答案
作为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.
相关推荐
最新文章