Binding custom dependency property to custom WPF style

前端 未结 1 413
萌比男神i
萌比男神i 2021-01-05 05:32

I have an issue when designing a inherited Expander. My intention is to have a progress bar behind the toggle button and text in the default Expander header.

I have

相关标签:
1条回答
  • 2021-01-05 06:27

    In the style, we can use a standard Binding with a RelativeSource to set up the property.

    <ProgressBar Name="ProgressBar"
                 Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Progress}"
                 Minimum="0"
                 Maximum="100" />
    

    Then, in the window we just add Progress="50" or a binding to somewhere else.

    You will also need to set the Button's background to transparent, or change some manner of the layout, in order to see it.

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