Using a TemplateBinding in ControlTemplate.Triggers

前端 未结 2 656
我寻月下人不归
我寻月下人不归 2021-02-07 03:16

Why does the following piece of XAML give me a XamlParseException with the (meaningless) message \"Expression type is not a valid Style value.\" at runtime?

<         


        
相关标签:
2条回答
  • 2021-02-07 03:40

    Triggers work best when defined in stand-alone styles, not in-place content. Try defining your trigger in a style resource, then reference the style resource from your template.

    0 讨论(0)
  • 2021-02-07 03:42

    Binding TemplatedParent: In this line the value of the path2 is going to apply for the Text property of the TextBlock, so it runs fine.

    In TemplateBinding : Have a close look at this, The resolved value of the Max:MyControl.Bar is going to act as the resource key for the Template binding [Here the value of Bar is not an actual value, instead it s a property key name ] which doesnt exists and so it throws the error "The given key was not present in the dictionary."

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