zoukankan      html  css  js  c++  java
  • 六、画刷

    第一,找一个类的子类

    工程中的引用——〉打开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;      

       }

  • 相关阅读:
    scala环境配置+hello world!
    mysql无法登录
    ajax跨域
    jfinal框架页面找不到相关css,js文件404
    从程序员到CTO的Java技术路线图 作者:zz563143188
    在項目中快速部署SLF4J+LOGBACK
    Spring整合MyBatis
    SpringMVC常用注解實例詳解3:@ResponseBody
    浏览器包含哪些进程?
    前端程序员也需要知道进程和线程
  • 原文地址:https://www.cnblogs.com/suinuaner/p/six.html
Copyright © 2011-2022 走看看