後臺程式碼引用資源字典樣式
阿新 • • 發佈:2018-12-26
1.資源字典定義:
2.後臺程式碼<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="Button" x:Key="GroupBoxButton"> <Setter Property="Width" Value="72"/> <Setter Property="Height" Value="30"/> <Setter Property="Margin" Value="5"/> <Setter Property="Background" Value="Black"/> </Style> </ResourceDictionary>
Button b = new Button();
b.Style = FindResource("GroupBoxButton") as Style;