Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How should I modify my code to make the corners of my button rounded?

<UserControl x:Class="WindowsFormsApplication8.UserControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="154" Width="177">
    <Grid>
        
        <Rectangle Name="rectangle1" Stroke="Black" RadiusX="10" RadiusY="10" >
        </Rectangle>

        <Button Name="rectangle2" Foreground="Black" Margin="3,3,3,3" >
            <Button.Background >
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Color="Green" Offset="0.0" />
                    <GradientStop Color="White" Offset="0.9" />
                </LinearGradientBrush>
            </Button.Background>
        </Button>
    </Grid>
</UserControl>


What is the simplest way?
Posted
Comments
Member 10771181 18-Jun-14 9:38am    
set required background view to rectangle and keep button's background as transparent.

To get round edged corners, you have to use a control template.
I have explained that in my blog :
http://tarundotnet.wordpress.com/2011/02/22/a-rounded-edged-button-in-wpf/[^]

Hope it helped!
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 28-Feb-11 4:50am    
Nice example! 5+
Tarun.K.S 28-Feb-11 5:00am    
Thanks! :)
aravinth santosh 21-May-15 11:45am    
nice link
Have a look at this article: A Style for Round Glassy WPF Buttons[^]
 
Share this answer
 
Comments
Manfred Rudolf Bihy 28-Feb-11 4:48am    
Link to a great article! 4+
Sandeep Mewara 28-Feb-11 9:16am    
Thanks Manfred.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900