ElementName Binding is failing

后端 未结 3 1887
别跟我提以往
别跟我提以往 2020-11-29 23:50

I have the following XAML:


    
        ...
    
    
         


        
相关标签:
3条回答
  • 2020-11-30 00:19

    I'm guessing that the writer of Chart, when deriving from FrameworkElement or whatever, failed to realize that they needed to add any child elements to the logical tree either manually or through an override. You don't get that for free when deriving.

    Breaking the logical tree breaks the ability of children to bind by ElementName.

    If you are the author of the Chart object, you can see this related question and answer.

    0 讨论(0)
  • 2020-11-30 00:20

    You might not have a namescope where you try to bind, you could try to replace the ElementName construct with Source={x:Reference DisplayMarkers}.

    For a workaround for potential cyclical dependency errors see: https://stackoverflow.com/a/6858917/546730

    0 讨论(0)
  • 2020-11-30 00:26

    For other readers, another possible cause is using a UserControl instead of a custom control for what's in the role of vf:Chart, above. I wrote a split button (in the role of the chart) and changing it from a UserControl to a custom control got my ElementName binding working.

    0 讨论(0)
提交回复
热议问题