I just realized that deriving from default style fails in my WPF app and I have no idea, why. Actually it works, but only due to "Hot reload". So I have:
<Style TargetType="ComboBox" x:Key="TestStyle" BasedOn="{StaticResource {x:Type ComboBox}}"/>
<Style TargetType="ComboBox">
<Setter Property="Width" Value="100"/>
</Style>
in resource dictionary, and:
<ComboBox Style="{StaticResource TestStyle}">
<ComboBoxItem>test</ComboBoxItem>
<ComboBoxItem>I want to cry with blood</ComboBoxItem>
</ComboBox>
in my control. When I start app I see following:
And when I remove BasedOn="{StaticResource {x:Type ComboBox}}"
and add it again, I have correct view:
What can be a reason of such behavior? Seems like WPF bug, but I don't think this is possible
question from:
https://stackoverflow.com/questions/66048560/deriving-style-from-base-style-fails-wpf 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…