WPF异常终止
就是在App.xaml里写了个渐变的按钮背景,运行起来就异常终止,求原因!代码如下
<Application.Resources>
<Style TargetType="Button">
<Setter Property="Width" Value="90"/>
<Setter Property="Margin" Value="10"/>
</Style>
<LinearGradientBrush x:Key="GrayBlueGradientBrush" StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="DarkBlue" Offset="0"/>
<GradientStop Color="AntiqueWhite" Offset="0.5"/>
<GradientStop Color="AliceBlue" Offset="1"/>
</LinearGradientBrush>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource GrayBlueGradientBrush}"/>
<Setter Property="Width" Value="80"/>
<Setter Property="Margin" Value="10"/>
</Style>
</Application.Resources>
------解决方案--------------------<Setter Property="Width" Value="80"/>
<Setter Property="Margin" Value="10"/>
把这2行去掉 设置2遍了
TargetType 也不明确 最好把 2个 针对button的Style合并起来
如果不能合并就设置一个X:key 单独引用