日期:2014-06-10  浏览次数:20676 次

1.SolidColorBrush(纯色画刷):

2.LinearGradientBrush(线性渐变画刷):

3.RedialGradientBrush(径向渐变画刷):

4.ImageBrush(图像画刷):

5.VideoBrush(视频画刷):

1.SolidColorBrush(纯色画刷):
1         <Rectangle RadiusX="3" RadiusY="3">
2             <Rectangle.Fill>
3                 <SolidColorBrush Color="GreenYellow"></SolidColorBrush>
4             </Rectangle.Fill>
5         </Rectangle>
2.LinearGradientBrush(线性渐变画刷): 
 1         <StackPanel Grid.Column="1">
 2             <StackPanel.Background>
 3                 <LinearGradientBrush StartPoint="1,0" EndPoint="1,1">
 4                     <GradientStopCollection>
 5                         <GradientStop Offset="0.1" Color="Red"></GradientStop>
 6                         <GradientStop Offset="0.5" Color="Orange"></GradientStop>
 7                         <GradientStop Offset="0.9" Color="Green"></GradientStop>
 8                     </GradientStopCollection>
 9                 </LinearGradientBrush>
10             </StackPanel.Background>
11         </StackPanel>
3.RedialGradientBrush(径向渐变画刷): 
 1         <Rectangle Grid.Column="0" Grid.Row="1" >
 2             <Rectangle.Fill>
 3                 <RadialGradientBrush Center="0.5,0.5"  GradientOrigin="0.5,0.5">
 4                     <GradientStop Offset="0" Color="White"></GradientStop>
 5                     <GradientStop Offset="0.5" Color="Green"></GradientStop>
 6                     <GradientStop Offset="0.7" Color="Blue"></GradientStop>
 7                     <GradientStop Offset="0.9" Color="Yellow"></GradientStop>
 8                 </RadialGradientBrush>
 9             </Rectangle.Fill>
10         </Rectangle>
4.ImageBrush(图像画刷): 
1         <TextBox Grid.Column="1" Grid.Row="1">
2             <TextBox.Background>
3                 <ImageBrush ImageSource="/Brush;component/image/xinghun.jpg" Stretch="Fill"></ImageBrush>
4             </TextBox.Background>
5         </TextBox>
5.VideoBrush(视频画刷): 
1 <MediaElement Name="SX" Source="/Brush;component/image/水仙.wmv" Grid.Row="2">
2 </MediaElement>
3 <TextBox Grid.Column="1" Grid.Row="2">
4     <TextBox.Background>
5          <VideoBrush SourceName="SX" Stretch="Fill"></VideoBrush>
6     </TextBox.Background>
7 </TextBox>
 
 1     <Grid x:Name="LayoutRoot" Background="White">
 2         <Grid.ColumnDefinitions>
 3             <ColumnDefinition></ColumnDefinition>
 4             <ColumnDefinition></ColumnDefinition>
 5         </Grid.ColumnDefinitions>
 6         <Grid.RowDefinitions>
 7             <RowDefinition></RowDefinition>
 8             <RowDefinition></RowDefinition>
 9             <RowDefinition></RowDefinition>
10         </Grid.RowDefinitions>
11         <Rectangle RadiusX="3" RadiusY="3">
12             <Rectangle.Fill>
13                 <SolidColorBrush Color="GreenYellow"></SolidColorBrush>
14             </Rectangle.Fill>
15         </Rectangle>
16         <StackPanel Grid.Column="1">
17             <StackPanel.Background>
18                 <LinearGradientBrush StartPoint="1,0" EndPoint="1,1">
19                     <GradientStopCollection>
20                         <GradientStop Offset="0.1" Color="Red"></GradientStop>
21                         <GradientStop Offset="0.5" Color="Orange"></GradientStop>
22                         <GradientStop Offset="0.9" Color="Green"></GradientStop>
23                     </GradientStopCollection>
24                 </LinearGradientBrush>
25             </StackPanel.Background>
26         </StackPanel>
27         <Rectangle Grid.Column="0" Grid.Row="1" >
28             <Rectangle.Fill>
29                 <RadialGradientBrush Center="0.5,0.5"  GradientOrigin="0.5,0.5">
30                     <GradientStop Offset="0" Color="White"></GradientStop>
31                     <GradientStop Offset="0.5" Color="Green"></GradientStop>
32                     <GradientStop Offset="0.7" Color="Blue"></GradientStop>
33                     <GradientStop Offset="0.9" Color="Yellow"></GradientStop>
34                 </RadialGradientBrush>
35             </Rectangle.Fill>
36         </Rectangle>
37         <TextBox Grid.Column="1" Grid.Row="1">
38             <TextBox.Background>
39                 <ImageBrush ImageSource="/Brush;component/image/xinghun.jpg" Stretch="Fill"></ImageBrush>
40             </TextBox.Background>
41         </TextBox>
42         <MediaElement Name="SX" Source="/Brush;component/image/水仙.wmv" Grid.Row="2" Grid.Column="0">
43         </MediaElement>
44         <TextBox Grid.Column="1" Grid.Row="2">
45             <TextBox.Background>
46                 <VideoBrush SourceName="SX" Stretch="Fill"></VideoBrush>
47             </TextBox.Background>
48         </TextBox>
49     </Grid>
View Code