This repository was archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
This repository was archived by the owner on Mar 8, 2024. It is now read-only.
A more compact Style format #235
Copy link
Copy link
Open
Description
Allow us to write Styles like this:
<Style Key="Style1" TargetType="Control">
<Set
Foreground = "#66603a"
Background = "#fff4e4"
BorderBrush = "Red"
BorderThickness = ".5,.5,1.5,1.5"
FontFamily = "Times New Roman"
FontSize= "18"
FontWeight = "Bold"
FontStyle = "Oblique"
Padding = "5"
Margin = "10" />
<Handle MouseEnter ="Control_MouseEnter"/>
</Style>this is more compact and more readable than:
<Style Key="Style1" TargetType="Control">
<Setter Property="Control.Foreground" Value="#66603a" />
<Setter Property="Control.Background" Value="#fff4e4"/>
<Setter Property="Control.BorderBrush" Value="Red"/>
<Setter Property="Control.BorderThickness" Value=".5,.5,1.5,1.5"/>
<Setter Property="Control.FontFamily" Value="Times New Roman" />
<Setter Property="Control.FontSize" Value="18" />
<Setter Property="Control.FontWeight" Value="Bold" />
<Setter Property="Control.FontStyle" Value="Oblique"/>
<Setter Property="Control.Padding" Value="5" />
<Setter Property="Control.Margin" Value="10" />
<EventSetter Event="MouseEnter" Handler="Control_MouseEnter"/>
</Style>For complex value, there is a little to enhance:
<Style>
<Set BorderBrush="new()">
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</LinearGradientBrush>
</Set>
</Style>instead of
<Style>
<Setter Property="BorderBrush" >
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="Yellow" Offset="0.0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1.0" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels