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;      

       }

  • 相关阅读:
    SqlServer实现Oracle的wm_concat()函数功能
    WebApi异常过滤器
    C#DataTable转List<Models>
    C#访问Oracle或SqlServer数据库遍历添加参数
    C#+.netFrameWork4.5.2+WebAPI+Jquery+Ajax跨域请求问题
    VS2015+Windows服务简易教程+文件夹监听
    C# rpt 批量打印写法
    C#model序列化xml
    oracle em无法连接数据库实例
    childNodes与children
  • 原文地址:https://www.cnblogs.com/suinuaner/p/six.html
Copyright © 2011-2022 走看看