Permalink
Browse files

new CornerRadius property for Buttons

  • Loading branch information...
1 parent 8b3b2cd commit efdc5f8e57a3b85d81969bd04dc7ff27e199e9ea @punker76 punker76 committed Feb 22, 2015
Showing with 30 additions and 2 deletions.
  1. +30 −2 MahApps.Metro/Controls/Helper/ButtonHelper.cs
@@ -6,8 +6,10 @@ namespace MahApps.Metro.Controls
public static class ButtonHelper
{
public static readonly DependencyProperty PreserveTextCaseProperty =
- DependencyProperty.RegisterAttached("PreserveTextCase", typeof(bool), typeof(ButtonHelper), new FrameworkPropertyMetadata(false,
- FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure));
+ DependencyProperty.RegisterAttached("PreserveTextCase", typeof(bool), typeof(ButtonHelper),
+ new FrameworkPropertyMetadata(
+ false,
+ FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure));
/// <summary>
/// Overrides the text case behavior for certain buttons.
@@ -23,5 +25,31 @@ public static void SetPreserveTextCase(UIElement element, bool value)
{
element.SetValue(PreserveTextCaseProperty, value);
}
+
+ /// <summary>
+ /// DependencyProperty for <see cref="CornerRadius" /> property.
+ /// </summary>
+ public static readonly DependencyProperty CornerRadiusProperty
+ = DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ButtonHelper),
+ new FrameworkPropertyMetadata(
+ new CornerRadius(),
+ FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
+
+ /// <summary>
+ /// The CornerRadius property allows users to control the roundness of the button corners independently by
+ /// setting a radius value for each corner. Radius values that are too large are scaled so that they
+ /// smoothly blend from corner to corner. (Can be used e.g. at MetroButton style)
+ /// Description taken from original Microsoft description :-D
+ /// </summary>
+ [AttachedPropertyBrowsableForType(typeof(Button))]
+ public static CornerRadius GetCornerRadius(UIElement element)
+ {
+ return (CornerRadius)element.GetValue(CornerRadiusProperty);
+ }
+
+ public static void SetCornerRadius(UIElement element, CornerRadius value)
+ {
+ element.SetValue(CornerRadiusProperty, value);
+ }
}
}

0 comments on commit efdc5f8

Please sign in to comment.