DependencyProperty not triggered

前端 未结 2 1000
我在风中等你
我在风中等你 2020-11-30 14:21

I defined property in my usercontrol like this:

 public bool IsSelected 
 {
     get { return (bool)GetValue(IsSelectedProperty); }
     set
     {
                  


        
2条回答
  •  無奈伤痛
    2020-11-30 14:51

    The setter of your dependency property will not be called when the property is set in XAML. WPF will instead call the SetValue method directly.

    See MSDN XAML Loading and Dependency Properties for an explanation why the setter is not called.

    You would have to register a PropertyChangedCallback with property metadata.

提交回复
热议问题