WPF,属性继承问题
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Foreground="Red">
<StackPanel >
<Label Content="熊俊" /> <TextBlock Text="12334" />
</StackPanel>
</Window>
<GradientStop Color="Green"></GradientStop>
<GradientStop x:Name="gcc1" Color="Green" Offset="0.3"></GradientStop>
<GradientStop x:Name="gcc2" Color="Blue" Offset="0.3"></GradientStop>
<GradientStop Color="Blue" Offset="1"></GradientStop>
</LinearGradientBrush>
</TextBlock.Foreground>
你看看这段代码,希望对你有帮助,这是设置的TextBlock的属性颜色,改成Lable就行了
[解决办法]
这东西自己不支持继承的话,你改模板也不行,除非设置个依赖项属性进行统一绑定,那样也不麻烦。
[解决办法]
<StackPanel >
<Label Content="熊俊" Foreground="Red" />
</StackPanel>