Permalink
Browse files

Merge branch 'punker76-ButtonHelper-breaking-change-fix' into develop

  • Loading branch information...
punker76 committed Jan 27, 2017
2 parents e0a01ef + 75a3d0e commit 7fcc6b770c77f483eb038705b252cfa7624a343f
@@ -15,19 +15,14 @@ public static class ButtonHelper
new FrameworkPropertyMetadata(
false,
FrameworkPropertyMetadataOptions.Inherits | FrameworkPropertyMetadataOptions.AffectsMeasure,
PreserveTextCasePropertyChangedCallback));
private static void PreserveTextCasePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue is bool)
{
var button = dependencyObject as Button;
if (button != null)
{
ControlsHelper.SetContentCharacterCasing(button, (bool)e.NewValue ? CharacterCasing.Normal : CharacterCasing.Upper);
}
}
}
(o, e) =>
{
var button = o as ButtonBase;
if (button != null && e.NewValue is bool)
{
ControlsHelper.SetContentCharacterCasing(button, (bool)e.NewValue ? CharacterCasing.Normal : CharacterCasing.Upper);
}
}));
/// <summary>
/// Overrides the text case behavior for certain buttons.
@@ -52,9 +47,17 @@ public static void SetPreserveTextCase(UIElement element, bool value)
public static readonly DependencyProperty CornerRadiusProperty
= DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ButtonHelper),
new FrameworkPropertyMetadata(
new CornerRadius(),
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender));
new CornerRadius(-1), // this is not valid, but this property is obsolete, set this to -1 to get the fired property changed callback
FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender,
(o, e) =>
{
var element = o as UIElement;
if (element != null && e.OldValue != e.NewValue && e.NewValue is CornerRadius)
{
ControlsHelper.SetCornerRadius(element, (CornerRadius)e.NewValue);
}
}));
/// <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
@@ -66,12 +69,12 @@ public static void SetPreserveTextCase(UIElement element, bool value)
[AttachedPropertyBrowsableForType(typeof(ToggleButton))]
public static CornerRadius GetCornerRadius(UIElement element)
{
return ControlsHelper.GetCornerRadius(element);
return (CornerRadius)element.GetValue(CornerRadiusProperty);
}
public static void SetCornerRadius(UIElement element, CornerRadius value)
{
ControlsHelper.SetCornerRadius(element, value);
element.SetValue(CornerRadiusProperty, value);
}
}
}
@@ -171,17 +171,27 @@ public static void SetHeaderMargin(UIElement element, Thickness value)
[Obsolete(@"This property will be deleted in the next release. You should use TextBoxHelper.ButtonWidth instead.")]
public static readonly DependencyProperty ButtonWidthProperty =
DependencyProperty.RegisterAttached("ButtonWidth", typeof(double), typeof(ControlsHelper),
new FrameworkPropertyMetadata(22d, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.Inherits));
new FrameworkPropertyMetadata(
22d,
FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.Inherits,
(o, e) =>
{
var element = o as UIElement;
if (element != null && e.OldValue != e.NewValue && e.NewValue is double)
{
TextBoxHelper.SetButtonWidth(element, (double)e.NewValue);
}
}));
[Category(AppName.MahApps)]
public static double GetButtonWidth(DependencyObject obj)
{
return TextBoxHelper.GetButtonWidth(obj);
return (double)obj.GetValue(ButtonWidthProperty);
}
public static void SetButtonWidth(DependencyObject obj, double value)
{
TextBoxHelper.SetButtonWidth(obj, value);
obj.SetValue(ButtonWidthProperty, value);
}
public static readonly DependencyProperty FocusBorderBrushProperty = DependencyProperty.RegisterAttached("FocusBorderBrush", typeof(Brush), typeof(ControlsHelper), new FrameworkPropertyMetadata(Brushes.Transparent, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits));

0 comments on commit 7fcc6b7

Please sign in to comment.