Binding on DependencyProperty of custom User Control not updating on change

后端 未结 2 929
死守一世寂寞
死守一世寂寞 2021-01-17 13:16

I\'m having difficulties with databinding on my custom user control (s). I created an example project to highlight my problem. I\'m completely new to WPF and essentially MVV

2条回答
  •  余生分开走
    2021-01-17 13:39

    Your change callback is breaking the binding.

    As a skeleton: in your window you have UC.X="{Binding A}" and then in that property change (in UC) you have X=B;. This breaks the binding since in both cases you set X.

    To rectify, remove change callback and add this to the label:

     Content="{Binding MinutesRemaining, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
    

提交回复
热议问题