Draw an Ellipse in WPF using VB.NET

In this short article I will explain how to draw and fill color an Ellipse in WPF.
  • 2281

WPF provides the drawing facility to understand with an example we create an ellipse and fill color in that. To draw an Ellipse open a WPF application and write down this this code:

    <
Window x:Class="WpfApplication4.Window1"
    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <
Grid
>
        <
Grid.Resources
>
            <
ControlTemplate x:Key
="buttonTemplate">
                <
Grid
>
                    <
Ellipse Width="200" Height
="120">
                        <
Ellipse.Fill
>
                            <
LinearGradientBrush StartPoint="0,0" EndPoint
="0,1">
                                <
GradientStop Offset="1" Color="Blue"></GradientStop
>
                            </
LinearGradientBrush
>
                        </
Ellipse.Fill
>
                    </
Ellipse
>
                </
Grid
>
            </
ControlTemplate
>
        </
Grid.Resources
>
        <
Button Template="{StaticResource buttonTemplate}">Click Me</Button
>
    </
Grid
>
    </
Window>

After writing this code run the application by hitting F5 on keyboard the output window shows like:

Output

ellipse.gif 

Conclusion

Hope this article help you to understanding the drawing tool of WPF.

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.