Hi Trian555,
如果你想设置默认的TextBlock的字体颜色, 但是又不影响其他控件或者控件模板内的字体颜色, 你可以这样做:
<Window.Resources>
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="Red" />
</Style>
</Window.Resources>
<Button
Name="btn2"
Width="200"
Height="30"
Content="this is test" />
<Button Name="btn3" Content="btn3" Margin="10">
<Button.Template>
<ControlTemplate>
<StackPanel Orientation="Horizontal">
<Image
Width="100"
Height="100"
Source="/Photo/1.jpg" />
<TextBlock VerticalAlignment="Center" Text="btn3" />
</StackPanel>
</ControlTemplate>
</Button.Template>
</Button>
<TextBlock
Name="textblock1"
Width="300"
Height="30"
Margin="10"
Text=" this is test" />
你可以看出只是TextBlock的字体颜色有变化, button或者button模板内的textblock字体颜色并没有变化。
Best Regards,
Cherry
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com.