Converter with Dependency Properties

后端 未结 2 801
情书的邮戳
情书的邮戳 2021-01-24 10:35

I have problems implementing a custom DependencyObject:

I need a converter which sets or unsets a enum flag in a bound property. Therefore I created a IValueConverter d

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-24 11:26

    A converter is not a FrameworkElement so it should not inherit from that class, at best use DependencyObject.

    Since the converter is not in any tree that binding will not work, you can try:

    
    

    (However this should be placed in the Resources of the UserControl and referenced, otherwise the x:Reference will cause a cyclical dependency error.)

    Note that the Flag binding tries to bind to the DataContext which might not work as the DataContext may not be inherited for the same reasons that ElementName and RelativeSource will not work.

提交回复
热议问题