自学WPF--第四课笔刷

 

笔刷可以通过填充颜色,已有图像使控件出现一种特种效果,从而达到一种意想不到的效果。

常用笔刷有以下几种:

<SolidColorBursh></SolidColorBrush>实体笔刷,以一种颜色填充空间。

<ImageBrush></ImageBrush>图像笔刷,以图像填充控件。

<ImageBrush>重要属性如下:

 ImageSource:设置笔刷图像源路径,Stretch:设置图像重叠方式,ViewBox:设置图像显示位置,TileMode设置重叠方式。

 

代码如下:

    <Grid>

<Ellipse Height="57" HorizontalAlignment="Left" Margin="12,242,0,0" Name="ellipse1" Stroke="Black" VerticalAlignment="Top" Width="101" >

            <Ellipse.Fill>               

                <ImageBrush ImageSource="images/1.jpg"></ImageBrush>

            </Ellipse.Fill>

        </Ellipse>

        <Ellipse Height="57" HorizontalAlignment="Left" Margin="119,242,0,0" Name="ellipse2" Stroke="Black" VerticalAlignment="Top" Width="104" >

            <Ellipse.Fill>

                <ImageBrush ImageSource="images/1.jpg" Stretch="None"/>

            </Ellipse.Fill>

        </Ellipse>

        <Ellipse Height="49" HorizontalAlignment="Left" Margin="242,242,0,0" Name="ellipse3" Stroke="Black" VerticalAlignment="Top" Width="99" >

            <Ellipse.Fill>

                <ImageBrush  ImageSource="images/1.jpg" Viewbox="0,0,0.5,0.5"/>

            </Ellipse.Fill>

        </Ellipse>

        <Ellipse Height="56" HorizontalAlignment="Left" Margin="347,235,0,0" Name="ellipse4" Stroke="Black" VerticalAlignment="Top" Width="108" >

            <Ellipse.Fill>

                <ImageBrush ImageSource="images/2.bmp" Viewbox="0,0,0.3,0.5" TileMode="FlipX"/>

            </Ellipse.Fill>

        </Ellipse>

        <TextBox Height="23" HorizontalAlignment="Left" Margin="24,25,0,0" Name="txtInput" FontFamily="Arial Black" VerticalAlignment="Top" Width="140" >

            <TextBox.Foreground>

                <ImageBrush ImageSource="images/1.jpg"/>

            </TextBox.Foreground>

            <TextBox.Background>

                <ImageBrush ImageSource="images/2.bmp"/>

            </TextBox.Background>

        </TextBox>

        <TextBlock Height="43" HorizontalAlignment="Left" Margin="32,75,0,0" Name="textBlock1" FontSize="24" Text="Hello WPF" VerticalAlignment="Top" Width="132">

        <TextBlock.Foreground>

            <ImageBrush ImageSource="images/1.jpg"/>

        </TextBlock.Foreground>

        </TextBlock>

    </Grid>

本文来自圣兽的博客,原文地址:http://blog.sina.com.cn/s/blog_685269a50100qtm7.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值