">
当前位置:   article > 正文

自学WPF--第四课笔刷_
作者:weixin_40725706 | 2024-03-18 17:07:49

 

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

常用笔刷有以下几种:

<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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/264533
推荐阅读
相关标签
  

闽ICP备14008679号