SL基础(三)

代码
<UserControl x:Class="SilverlightApplication5.MainPage"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d
="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc
="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable
="d"
    d:DesignHeight
="300" d:DesignWidth="400">

    
<Grid x:Name="LayoutRoot" Background="White">
        
<Canvas Height="300" Width="300">
            
<!-- 划线 -->
            
<Line X1="10" Y1="10" X2="50" Y2="50" Stroke="Red" StrokeThickness="3"></Line>
            
            
<!-- 自定义Stroke属性 -->       
            
<Line X1="10" Y1="10" X2="50" Y2="50" StrokeThickness="30" Canvas.Left="100">
                
<Line.Stroke>
                    
<RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
                        
<RadialGradientBrush.GradientStops>
                            
<GradientStop Color="Yellow" Offset="0"/>
                            
<GradientStop Color="Green" Offset="0.5"></GradientStop>
                        
</RadialGradientBrush.GradientStops>
                    
</RadialGradientBrush>
                
</Line.Stroke>
            
</Line>
            
<!--  划水平线  -->
            
<Line X1="10" Y1="60" X2="500" Y2="60" Stroke="Black" StrokeThickness="5"></Line>
            
            
<!--  Ellipse  -->
            
<Ellipse Width="50" Height="100" Fill="CadetBlue" Stroke="Azure" StrokeThickness="3" Canvas.Left="300"></Ellipse>
            
            
<!--  Path 注意理解Path中的Data 贝赛尔曲线 -->
            
<Path Stroke="DarkGoldenrod" StrokeThickness="3" Data="M 100,200 C 100,25 400,350 400,175 H 280"/>
            
            
<!--绘制形状-->
            
<Ellipse Canvas.Left="50" Canvas.Top="50"
                     Fill
="DarkOliveGreen" Height="75" Width="75"
                     Stroke
="Yellow"
                     StrokeThickness
="3"/>
            
            
<!--  显式创建多边形 -->
            
<Polygon
                Points
="300,200 400,125 400,275 300,200"
                Stroke
="Purple"
                StrokeThickness
="2">
                
<Polygon.Fill>
                   
<SolidColorBrush Color="Blue" Opacity="0.4"/>
                
</Polygon.Fill>
            
</Polygon>
            
            
<!--变换形状-->
            
<Rectangle Width="50" Height="50" Fill="RoyalBlue">
                
<Rectangle.RenderTransform>
                    
<RotateTransform Angle="45"/>
                
</Rectangle.RenderTransform>
            
</Rectangle>

        
</Canvas>
        
<Canvas  Width="200" Height="200">
            
<Path Stroke="Black" StrokeThickness="1">
                
<Path.Data>
                    
<LineGeometry StartPoint="10,20" EndPoint="100,130"/>
                
</Path.Data>
            
</Path>
            
        
</Canvas>
    
</Grid>
    
</UserControl>
原文地址:https://www.cnblogs.com/chenqingwei/p/1961254.html