我的 Windows.Resources 添加了以下样式
<Window.Resources>
...
<!--A Style that extends the previous TextBlock Style-->
<!--This is a "named style" with an x:Key of TitleText-->
<Style BasedOn="{StaticResource {x:Type TextBlock}}"
TargetType="TextBlock"
x:Key="TitleText">
<Setter Property="FontSize" Value="26"/>
<Setter Property="Foreground">
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<LinearGradientBrush.GradientStops>
<GradientStop Offset="0.0" Color="#90DDDD" />
<GradientStop Offset="1.0" Color="#5BFFFF" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
...
</Window.Resources>
我的 xaml 代码中有很多这样的样式,我想将每个组件样式保存到一个额外的文件(不是外部文件)中。例如,与 TextBlocks 相关的所有样式都应该在一个名为TextBlockStyles.xaml
我将如何在 wpf 中执行此操作?
如何在我的项目中链接样式?
提前致谢