六、画刷

第一,找一个类的子类

工程中的引用——〉打开windows——〉在浏览器中查找windows——〉在搜索框中输入父类——〉打开派生类型,即可。

第二,给button添加背景色

(1) 实心颜色画刷

方法一:最常用和简单的      <Button Background="Red" />

方法二:标准写法

       <Button>

         <Button.Background>
                    <SolidColorBrush Color="Gold"></SolidColorBrush> 
                </Button.Background>

         </Button>

方法三:<Button>

         <Button.Background> Gold </Button.Background>

         </Button>

(2)线性渐变画刷

<Button>

<Button.Background>
                    <LinearGradientBrush>
                        <GradientStop Color="Red" Offset="0"></GradientStop>
                        <GradientStop Color="Yellow" Offset="0.7"></GradientStop>
                        <GradientStop Color="Blue" Offset="1"></GradientStop>
                    </LinearGradientBrush>
                </Button.Background>

</Button>

歌词的效果
第一步:在XAML中            <TextBlock Text="相信光明就在远方" FontSize="40" >
                <TextBlock.Foreground>
                    <LinearGradientBrush>
                        <GradientStop Color="Yellow" ></GradientStop>
                        <GradientStop Color="Yellow" Offset="0.3"></GradientStop>
                        <GradientStop Color="Red" Offset="0.3"></GradientStop>
                        <GradientStop Color="Red"  Offset="1"></GradientStop>
                    </LinearGradientBrush>
                </TextBlock.Foreground>
            </TextBlock>

第二步:在歌词所在的.cs文件中的OnNavigatedTo方法中加入一个定时器(新建的是空白页)

protected override void OnNavigatedTo(NavigationEventArgs e)        

{            

          DispatcherTimer timer = new DispatcherTimer();           

           timer.Interval = TimeSpan.FromMilliseconds(200);//每200毫秒,定时器执行一次         

           timer.Tick += timer_Tick;            

           timer.Start();

        }

        void timer_Tick(object sender, object e)       

  {            

             gs1.Offset += 0.01;            

             gs2.Offset += 0.01;      

   }

原文地址:https://www.cnblogs.com/suinuaner/p/six.html