Skip to content

Commit efdc5f8

Browse files
committed
new CornerRadius property for Buttons
1 parent 8b3b2cd commit efdc5f8

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

MahApps.Metro/Controls/Helper/ButtonHelper.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ namespace MahApps.Metro.Controls
66
public static class ButtonHelper
77
{
88
public static readonly DependencyProperty PreserveTextCaseProperty =
9-
DependencyProperty.RegisterAttached("PreserveTextCase", typeof(bool), typeof(ButtonHelper), new FrameworkPropertyMetadata(false,
10-
FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure));
9+
DependencyProperty.RegisterAttached("PreserveTextCase", typeof(bool), typeof(ButtonHelper),
10+
new FrameworkPropertyMetadata(
11+
false,
12+
FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure));
1113

1214
/// <summary>
1315
/// Overrides the text case behavior for certain buttons.
@@ -23,5 +25,31 @@ public static void SetPreserveTextCase(UIElement element, bool value)
2325
{
2426
element.SetValue(PreserveTextCaseProperty, value);
2527
}
28+
29+
/// <summary>
30+
/// DependencyProperty for <see cref="CornerRadius" /> property.
31+
/// </summary>
32+
public static readonly DependencyProperty CornerRadiusProperty
33+
= DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ButtonHelper),
34+
new FrameworkPropertyMetadata(
35+
new CornerRadius(),
36+
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
37+
38+
/// <summary>
39+
/// The CornerRadius property allows users to control the roundness of the button corners independently by
40+
/// setting a radius value for each corner. Radius values that are too large are scaled so that they
41+
/// smoothly blend from corner to corner. (Can be used e.g. at MetroButton style)
42+
/// Description taken from original Microsoft description :-D
43+
/// </summary>
44+
[AttachedPropertyBrowsableForType(typeof(Button))]
45+
public static CornerRadius GetCornerRadius(UIElement element)
46+
{
47+
return (CornerRadius)element.GetValue(CornerRadiusProperty);
48+
}
49+
50+
public static void SetCornerRadius(UIElement element, CornerRadius value)
51+
{
52+
element.SetValue(CornerRadiusProperty, value);
53+
}
2654
}
2755
}

0 commit comments

Comments
 (0)