样式太多 每个界面可能需要全局的样式
有没有肯能 WPF 中的样式 像Asp.net中 的CSS一样管理那
有的
有资源字典
BurshDictionary
- <LinearGradientBrush x:Key="RectFill" EndPoint="0.5,1" StartPoint="0.5,0">
- <GradientStop Color="BurlyWood" Offset="0"/>
- <GradientStop Color="White" Offset="1"/>
- </LinearGradientBrush>
在APP里加载全局
- <Application.Resources>
- <ResourceDictionary>
- <ResourceDictionary.MergedDictionaries>
- <ResourceDictionary Source="Themes/BurshDictionary.xaml"></ResourceDictionary>
- </ResourceDictionary.MergedDictionaries>
- </ResourceDictionary>
- </Application.Resources>
- </Application>
Main窗体里直接引用
- <Rectangle Fill="{ StaticResource RectFill}" HorizontalAlignment="Left" Height="76" Margin="85,70,0,0" Stroke="Black" VerticalAlignment="Top" Width="243">
- </Rectangle>
原文地址:https://www.cnblogs.com/lonelyxmas/p/12075518.html
时间: 2024-10-29 08:37:35