I am trying to create a round button, with a White Border and a Transparent Background (as the old AppBarButtons in Windows 8.1) in UWP Windows 10.
I have found several samples like these:
https://comentsys.wordpress.com/2015/05/23/windows-10-universal-windows-platform-custom-button/
But the problem is with the Border. When I setting the BorderBrush to a certain color, it turns out the Border is for Button's "Rectangle".
Is there a way I can create a Round border for a button?
With version
1809
and later (even if you're targeting an earlier version like me below) you can just do this for an example of a round button:and voila!
Make sure to add this at the top of your XAML with the other
xmlns
stuff.I don't know if the OP is still interested in rounded corner buttons, but for sake of completeness I think it may be helpful for other users to point out, as the user peterincumbria said, that for the lastest build of Windows 10 (1809) there is a new property in the class
Control
:CornerRadius
. So now the following code is enough:Put this inside a
Grid
and we have a rounded corner button in the middle of thePage
.The approach I just used was to simply add CornerRadius to the "RootGrid" grid in the Button template.
Another sample
Result
Or Create fully customizable cornerradius
//Create a template control xaml design
//Template control.cs
//Register to or merge dictionary from /Themes/Generic.xaml
There are few ways to achieve this, one by using a style can look like this - remove BorderBrush from ContentPresenter and add an Ellipse with that brush. Sample in XAML:
I've also made some changes in VisualStates so that it doesn't look weird once clicked/disabled.
Are you looking for something like this?