C# 全局样式不适用
这是我的C代码 在主窗口之后,导航到新的UserControl,全局样式 在App.xaml中定义C# 全局样式不适用,c#,wpf,xaml,styles,C#,Wpf,Xaml,Styles,这是我的C代码 在主窗口之后,导航到新的UserControl,全局样式 在App.xaml中定义 <Application.Resources> <Style TargetType="{x:Type UserControl}"> <Setter Property="Background" Value="Red" /> </Style> </Application.Resources> 不适用于它 但在Vi
<Application.Resources>
<Style TargetType="{x:Type UserControl}">
<Setter Property="Background" Value="Red" />
</Style>
</Application.Resources>
不适用于它
但在VisualStudio中,构造函数通过更改用户控件的背景来显示用户控件应用了该样式
我该怎么办?您确定用户控件本身没有设置背景值吗? 要查找诸如UserControl.Background WPF之类的依赖项属性的实际值,请使用设置顺序。如果直接设置背景特性,样式将不会覆盖它(请参见)
<Application.Resources>
<Style TargetType="{x:Type UserControl}">
<Setter Property="Background" Value="Red" />
</Style>
</Application.Resources>