DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

WPF circle button example

By Ashok Nalam on 10 Dec 2013 | Category: WPF | Tagged: button .NET 
  Discuss Add Comment   |  
Add rating Rate this resource   
To implement circular WPF Button use the following code.

XAML:
    <Grid>
        <Button  Width="50" Height="50" Content="Click me!" Click="Button_Click">
            <Button.Template>
                <ControlTemplate TargetType="Button">
                    <Grid>
                        <Ellipse Fill="Violet"/>
                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                </ControlTemplate>
            </Button.Template>
        </Button>
    </Grid>
Code:
private void Button_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("I am circle button");
}
Output:
WPF Circle Button

Note: In order to make button as circle, you must set the height and width to equal values.

  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9026  (Professional)
Location : INDIA
Home Page : http://dotnetmirror.com
About : I am admin of this site.
Rate this resource
 
Add your Comment
Name Email WebSite
Captcha Refresh


Comments (2)
 
1. By ZAP on 05 Dec 2022

 
2. By ZAP on 05 Dec 2022