Set custom attached property in style setter

时光毁灭记忆、已成空白 提交于 2019-11-29 16:39:01

The owner type of the attached property must be the class where it is declared, which is TestBehaviour here, not Grid. Change the declaration to:

public static readonly DependencyProperty TestProperty =
    DependencyProperty.RegisterAttached("Test", typeof(bool), typeof(TestBehaviour));

See the MSDN documentation for RegisterAttached:

ownerType - The owner type that is registering the dependency property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!