Posts Tagged ‘Drawing’

I experimented a few shapes with Silverlight.
If you just want to test in your Visual Studio 2008, copy the code and paste it into your IDE.
You do not need to do anything in C# or VB.

graphic_draw.jpg (41 KB)

<UserControl x:Class="GraphicDraw.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:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
        <Canvas>
            <Path Fill="Chocolate" Data="F1 M 75, 15 L 15, 150 L 150, 150" />
            <Rectangle Fill="Blue" Canvas.Left="100" Canvas.Top="160" Width="200" Height="150" />
            <Rectangle Fill="AliceBlue" Stroke="Black" StrokeThickness="10" Canvas.Left="200" Canvas.Top="50" Width="100" Height="100" />
            <Rectangle Fill="AliceBlue" Stroke="Black" StrokeThickness="10" RadiusX="40" RadiusY="40" Canvas.Left="380" Canvas.Top="50" Width="150" Height="200" />
            <Ellipse Fill="Red" Canvas.Left="300" Canvas.Top="260" Width="200" Height="150" />
            <Rectangle Width="500" Height="50" Canvas.Left="10" Canvas.Top="420">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0, 0" EndPoint="1, 1">
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Color="Yellow" Offset="0"/>
                            <GradientStop Color="Blue" Offset="1"/>
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
        </Canvas>
  </Grid>
</UserControl>

I hope it can be useful for you.