Live Chat Icon For mobile
Live Chat Icon

How do I change the shape of the button to an ellipse?

Platform: WPF| Category: Buttons

The button’s shape can be changed to any shape by applying the control template to a button. The following code snippet is used to change the shape of a button to an ellipse.

[XAML]

<ControlTemplate x:Key='Temp1' TargetType='{x:Type Button}'>
<Grid>
<Ellipse x:Name='Ell' Width='{TemplateBinding Width}' Height='50'>
<Ellipse.Fill>
            <LinearGradientBrush StartPoint='0,0.5' EndPoint='1,0.5'>
            <GradientStop Offset='0.3' Color='YellowGreen'/>
            <GradientStop Offset='1' Color='Green'/>
            </LinearGradientBrush>
            </Ellipse.Fill>
</Ellipse>
<Viewbox>
<ContentControl Margin='10' Content='{TemplateBinding Content}' FontSize='11' HorizontalContentAlignment='Center' Foreground='AntiqueWhite'/>
            </Viewbox>
</Grid>
</ControlTemplate>

<Button Name='Button1' Template='{StaticResource Temp1}'  Height='50' Width='80'>Templated Button</Button>

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.