C#样式的使用,添加自定义样式需对控件的属性相对熟悉,且需要对样式引用的格式熟悉(wpf对自定义样式中控件属性不给出提示,需自己写)。
下面是对StackPanel板式添加的自定义按钮样式
<!--样式-->
<Window x:Class="e2_19.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<!--布局Style-->
<Style x:Key="MyStyle1">
<Setter Property="StackPanel.Orientation" Value="Vertical"/>
<Setter Property="StackPanel.Background" Value="Gray"/>
<Setter Property="Button