forked from microsoft/WPF-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradientSpreadExample.xaml
161 lines (140 loc) · 6.91 KB
/
GradientSpreadExample.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!-- GradientSpreadExample.xaml
This example shows the different gradient spread methods applied to
linear and radial gradient brushes. -->
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Gradient Spread Methods">
<Page.Resources>
<Style x:Key="AxisMarkerStyle" TargetType="{x:Type Line}">
<Setter Property="StrokeThickness" Value="4"/>
<Setter Property="Stroke" Value="#FF3300"/>
<Setter Property="StrokeStartLineCap" Value="Flat"/>
<Setter Property="StrokeEndLineCap" Value="Flat"/>
</Style>
</Page.Resources>
<Grid Margin="10" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="10" />
<ColumnDefinition />
<ColumnDefinition Width="10" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="20" />
<RowDefinition Height="Auto" />
<RowDefinition Height="20" />
<RowDefinition Height="Auto" />
<RowDefinition Height="20" />
<RowDefinition Height="Auto" />
<RowDefinition Height="20" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Page and table header -->
<Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5"
Background="{StaticResource BlueHorizontalGradientBrush}">
<TextBlock Style="{StaticResource MyIntroTextBlockStyle}">
A GradientBrush's SpreadMethod specifies how areas outside of the gradient
axis are painted. The following are examples of the different SpreadMethod settings.
</TextBlock>
</Border>
<Rectangle Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="5" Fill="DarkGray" StrokeThickness="0" />
<!-- Labels the different examples. -->
<TextBlock Grid.Row="2" Grid.Column="0" Margin="10,10,0,10">Spread method</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="2" Margin="0,10,0,10">Linear gradient</TextBlock>
<TextBlock Grid.Row="2" Grid.Column="4" Margin="0,10,0,10">Radial gradient</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0" Margin="10,0,0,0">Pad</TextBlock>
<TextBlock Grid.Row="6" Grid.Column="0" Margin="10,0,0,0">Reflect</TextBlock>
<TextBlock Grid.Row="8" Grid.Column="0" Margin="10,0,0,0">Repeat</TextBlock>
<!-- The following three examples show the different gradient spread methods
applied to linear gradient brushes. -->
<Canvas Grid.Row="4" Grid.Column="2" Width="150" Height="75" Margin="0,0,0,10">
<Rectangle Width="150" Height="75" Stroke="Black">
<Rectangle.Fill>
<!-- Pad -->
<LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Pad">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Highlights the gradient axis. -->
<Line X1="45" Y1="40" X2="105" Y2="40" Style="{StaticResource AxisMarkerStyle}" />
</Canvas>
<Canvas Grid.Row="6" Grid.Column="2" Width="150" Height="75" Margin="0,0,0,10">
<Rectangle Width="150" Height="75" Stroke="Black">
<Rectangle.Fill>
<!-- Reflect -->
<LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Reflect">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Highlights the gradient axis. -->
<Line X1="45" Y1="40" X2="105" Y2="40" Style="{StaticResource AxisMarkerStyle}" />
</Canvas>
<Canvas Grid.Row="8" Grid.Column="2" Width="150" Height="75" Margin="0,0,0,10">
<Rectangle Width="150" Height="75" Stroke="Black">
<Rectangle.Fill>
<!-- Repeat -->
<LinearGradientBrush StartPoint="0.3,0.5" EndPoint="0.7,0.5" SpreadMethod="Repeat">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Highlights the gradient axis. -->
<Line X1="45" Y1="40" X2="105" Y2="40" Style="{StaticResource AxisMarkerStyle}" />
</Canvas>
<!-- The following three examples show the different gradient spread methods
applied to radial gradient brushes. -->
<Canvas Grid.Row="4" Grid.Column="4" Width="150" Height="75" Margin="0,0,0,10">
<Rectangle Width="150" Height="75" Stroke="Black">
<Rectangle.Fill>
<!-- Pad -->
<RadialGradientBrush Center="0.5,0.5" RadiusX="0.3" RadiusY="0.3" SpreadMethod="Pad">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</RadialGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Highlights the gradient axis. -->
<Line X1="75" Y1="15" X2="75" Y2="60" Style="{StaticResource AxisMarkerStyle}" StrokeThickness="2" />
<Line X1="30" Y1="37.5" X2="120" Y2="37.5" Style="{StaticResource AxisMarkerStyle}" StrokeThickness="2" />
</Canvas>
<Canvas Grid.Row="6" Grid.Column="4" Width="150" Height="75" Margin="0,0,0,10">
<Rectangle Width="150" Height="75" Stroke="Black">
<Rectangle.Fill>
<!-- Reflect -->
<RadialGradientBrush Center="0.5,0.5" RadiusX="0.3" RadiusY="0.3" SpreadMethod="Reflect">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</RadialGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Highlights the gradient axis. -->
<Line X1="75" Y1="15" X2="75" Y2="60" Style="{StaticResource AxisMarkerStyle}" StrokeThickness="2" />
<Line X1="30" Y1="37.5" X2="120" Y2="37.5" Style="{StaticResource AxisMarkerStyle}" StrokeThickness="2" />
</Canvas>
<Canvas Grid.Row="8" Grid.Column="4" Width="150" Height="75" Margin="0,0,0,10">
<Rectangle Width="150" Height="75" Stroke="Black">
<Rectangle.Fill>
<!-- Repeat -->
<RadialGradientBrush Center="0.5,0.5" RadiusX="0.3" RadiusY="0.3" SpreadMethod="Repeat">
<GradientStop Color="White" Offset="0" />
<GradientStop Color="#333333" Offset="1" />
</RadialGradientBrush>
</Rectangle.Fill>
</Rectangle>
<!-- Highlights the gradient axis. -->
<Line X1="75" Y1="15" X2="75" Y2="60" Style="{StaticResource AxisMarkerStyle}" StrokeThickness="2" />
<Line X1="30" Y1="37.5" X2="120" Y2="37.5" Style="{StaticResource AxisMarkerStyle}" StrokeThickness="2" />
</Canvas>
<Rectangle Style="{StaticResource FooterRectangleStyle}" Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="5" Fill="{StaticResource BlueHorizontalGradientBrush}" />
</Grid>
</Page>