ARTICLE

WPF Ellipse in VB.NET

Posted by Purushottam Rathore Articles | WPF using VB.NET September 22, 2010
This is a simple article to represent how to create Ellipse in WPF.
 
Reader Level:

Ellipse in WPF:

 

<Ellipse Width="190" Height="90">

    <Ellipse.Fill>

        <LinearGradientBrush>

            <GradientStop Offset="0" Color="Wheat"/>

            <GradientStop Offset="1" Color="White" />

        </LinearGradientBrush>

    </Ellipse.Fill>

</Ellipse>
 

How to use Ellipse on button's background?

<Button Height="100" Grid.Row="1" Grid.Column="1" Width="200">

    <Ellipse Width="190" Height="90">

        <Ellipse.Fill>

            <LinearGradientBrush>

                <GradientStop Offset="0" Color="Wheat"/>

                <GradientStop Offset="1" Color="White" />

            </LinearGradientBrush>

        </Ellipse.Fill>

    </Ellipse>

</Button>
 

Now I am taking a simple example to show how to create Ellipse on button's background and also how to show the message on messagebox using WPF.

Example:

MainWindow.xaml:
 

<Window x:Class="test_WPF.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow" Height="350" Width="525">

    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition Height="58" />

            <RowDefinition Height="122" />

            <RowDefinition Height="131*" />

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>

            <ColumnDefinition MinWidth="50" />

            <ColumnDefinition Width="Auto" />

            <ColumnDefinition Width="*" />

        </Grid.ColumnDefinitions>

        <TextBlock Text="Enter Name:" Grid.Row="0" Grid.Column="0" />

        <TextBox x:Name="txtName" Grid.Row="0" Grid.Column="1" MinWidth="50"/>

        <Button Height="100" Grid.Row="1" Grid.Column="1" Width="200" Click="Button_Click">

            <Ellipse Width="190" Height="90">

                <Ellipse.Fill>

                    <LinearGradientBrush>

                        <GradientStop Offset="0" Color="Wheat"/>

                        <GradientStop Offset="1" Color="White" />

                    </LinearGradientBrush>

                </Ellipse.Fill>

            </Ellipse>

        </Button>

    </Grid>

</Window>

 

Design view:

 

WPF1.png
 

MainWindow.xaml.cs:

Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes

Namespace test_WPF
    ''' <summary>
    ''' Interaction logic for MainWindow.xaml
    ''' </summary>
    Partial Public Class MainWindow
        Inherits Window
        Public Sub New()

            InitializeComponent()
        End Sub
        Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            MessageBox.Show(String.Format("Hello {0}", Me.txtName.Text))
        End Sub
    End Class
End Namespace

 

Output: Now debug this application and enter your name then the message box shows as follows:

 

WPF2.png

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Diagram
Become a Sponsor