这个 ModernUI TextBox 怎么来的
改变它的外观
当我所做的只是添加这种样式时:
<UserControl.Resources>
<Style TargetType="{x:Type TextBox}">
<Setter Property="TextAlignment" Value="Right"/>
</Style>
</UserControl.Resources>
当我直接在元素中设置属性时:
<TextBox Text="" TextAlignment="Right"></TextBox>
一切看起来都应该如此:
我真的不明白,如果能给我一个简短的提示,我将不胜感激。
最佳答案
问题是它将完全取代其他样式。
添加 BasedOn属性来指定此样式将扩展 ModernUI 样式:
<UserControl.Resources>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource whateverModernUIStyleNameIs}">
<Setter Property="TextAlignment" Value="Right"/>
</Style>
</UserControl.Resources>
您还可以指定隐式样式:BasedOn="{StaticResource {x:Type TextBox}}"
,正如 Mike C 所指出的。
阅读此问题了解更多详情:How to apply multiple styles in WPF
关于c# - 风格完全改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29679691/