WPF,Style中取父控件的属性值
作者:互联网
使用示例:
<Window.Resources> <Style x:Key="radioButtonStyle" TargetType="{x:Type ListBox}"> <Setter Property="ItemContainerStyle"> <Setter.Value> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <RadioButton Focusable="False" IsChecked="{Binding Path=IsSelected,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"> <ContentPresenter></ContentPresenter> </RadioButton> </ControlTemplate> </Setter.Value> </Setter> </Style> </Setter.Value> </Setter> </Style> </Window.Resources>
标签:控件,Style,示例,中取,WPF,属性 来源: https://www.cnblogs.com/JerryFly/p/16578860.html