+ -
当前位置:首页 → 问答吧 → 使用 Blend 来创建一个不规则 Border

使用 Blend 来创建一个不规则 Border

时间:2010-01-23

来源:互联网

设我们有一个空白项,对应的Xaml文件为:

<UserControl
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="SilverlightApplication4.MainPage"
        Width="640" Height="480">

        <Grid x:Name="LayoutRoot" Background="White"/>
UserControl>我们在其中增加一个 Border 控件,并用 钢笔或者铅笔画一个不规则图形。 这时候,产生的Xaml 文件类似如下:<UserControl
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="SilverlightApplication4.MainPage"
        Width="640" Height="480">

        <Grid x:Name="LayoutRoot" Background="White">
                <Border Height="115" Margin="103,47,102,0" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1">
                        <Path Fill="White" Stretch="Fill" Stroke="Black" Margin="73.5,35.598,149.5,12.5" UseLayoutRounding="False" Data="M83,46 C228,18 284,65 284,65 L217,100.99988 L177,79.999947 L141,93.999901 L75,76.999962 z"/>
                Border>
        Grid>
UserControl>然后我们在“对象和时间线中”选择我们要用的Path 对象,如下图: 点击 路径 --》 生成剪切路径在出现的 生成剪切路径选择窗口中,我们选择需要使用这个路径的对象,这里我们选择“Border” 对象 点击确定后,我们就可以获得一个不规则的 Border, 这时候的Xaml 文件为:<UserControl
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="SilverlightApplication4.MainPage"
        Width="640" Height="480">

        <Grid x:Name="LayoutRoot" Background="White">
                <Border Height="115" Margin="103,47,102,0" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="1" Clip="M83,45.999935 C228,17.999838 284,65 284,65 L217,101 L177,80 L141,94 L75,77 z"/>
        Grid>
UserControl>适当调整颜色后,看到的Border 就是如下图: 其他控件我们想要设计成不规则方式, 在Blend 中的设计步骤类似


转自:http://bbs.flatws.cn/thread-10606-1-1.html
 

作者: swlyb   发布时间: 2010-01-23

相关阅读 更多

热门下载

更多