WPF Shape Drawings in VB.NET

In this article you will learn about the Shape Drawings in WPF.
  • 3059

Shape object is an object through which you can draw different shapes, basically shape is a type of UIElement which helps you to draw different shapes to the screen and due to the reason this is an UIElement it used inside the panel element and most controls.

WPF provides a number of ready-to-use Shape objects. All shape objects inherit from the Shape class. Available shape objects include Ellipse, Line, Path, Polygon, Polyline, and Rectangle.

Windows Presentation Foundation (WPF) offers several layers of access to graphics and rendering services. At the top layer, Shape objects are easy to use and provide many useful features, such as layout and participation in the Windows Presentation Foundation (WPF) event system.

Example of an Shape draw:

<Canvas x:Class="WpfApplication1.MainWindow"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="300" Width="300">
        <Rectangle Width="369" Height="364" Stroke="Black" Canvas.Left="-130" Canvas.Top="-80">
                    <GradientStop Color="LightGray" Offset="0" />
                    <GradientStop Color="Snow" Offset=".75" />
                    <GradientStop Color="LightGray" Offset="1" />

        <!-- SAD Face -->
        <Ellipse Canvas.Top="-40" Canvas.Left="-89"
            Width="279" Height="278"
            Fill="Blue" Stroke="Black" />
        <Ellipse Canvas.Top="28" Canvas.Left="81"
            Width="50" Height="50"
            Fill="Black" />
        <Ellipse Canvas.Top="28" Canvas.Left="-39"
            Width="50" Height="50"
            Fill="Black" />
        <Path Stroke="Black" StrokeThickness="5"
            Data="M 100,275 S 200,225 300,275" Canvas.Left="-148" Canvas.Top="-96" />

            <!-- Text Message -->
            <TextBlock Canvas.Top="234" Canvas.Left="6"
            FontFamily="Comic Sans MS"
            FontSize="36" Foreground="Black"
            Text="SAD" />

Output Window



I hope this article help you to understand the basic Drawing functions in WPF.


More Articles

© 2020 DotNetHeaven. All rights reserved.