Skip to content

Commit

Permalink
new CornerRadius property for Buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Feb 22, 2015
1 parent 8b3b2cd commit efdc5f8
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions MahApps.Metro/Controls/Helper/ButtonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.