diff --git a/MahApps.Metro/Controls/ButtonsPlacementVariant.cs b/MahApps.Metro/Controls/ButtonsPlacementVariant.cs new file mode 100644 index 0000000000..9d3b957d4b --- /dev/null +++ b/MahApps.Metro/Controls/ButtonsPlacementVariant.cs @@ -0,0 +1,8 @@ +namespace MahApps.Metro.Controls +{ + public enum ButtonsPlacementVariant + { + Left, + Right + } +} diff --git a/MahApps.Metro/Controls/Helper/TextBoxHelper.cs b/MahApps.Metro/Controls/Helper/TextBoxHelper.cs index d3a2bf62b9..8cfc4d0c35 100644 --- a/MahApps.Metro/Controls/Helper/TextBoxHelper.cs +++ b/MahApps.Metro/Controls/Helper/TextBoxHelper.cs @@ -22,6 +22,7 @@ public class TextBoxHelper public static readonly DependencyProperty UseFloatingWatermarkProperty = DependencyProperty.RegisterAttached("UseFloatingWatermark", typeof(bool), typeof(TextBoxHelper), new FrameworkPropertyMetadata(false, ButtonCommandOrClearTextChanged)); public static readonly DependencyProperty TextLengthProperty = DependencyProperty.RegisterAttached("TextLength", typeof(int), typeof(TextBoxHelper), new UIPropertyMetadata(0)); public static readonly DependencyProperty ClearTextButtonProperty = DependencyProperty.RegisterAttached("ClearTextButton", typeof(bool), typeof(TextBoxHelper), new FrameworkPropertyMetadata(false, ButtonCommandOrClearTextChanged)); + public static readonly DependencyProperty ButtonsPlacementProperty = DependencyProperty.RegisterAttached("ButtonsPlacement", typeof(ButtonsPlacementVariant), typeof(TextBoxHelper), new FrameworkPropertyMetadata(ButtonsPlacementVariant.Right, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); /// /// The clear text button behavior property. It sets a click event to the button if the value is true. /// @@ -300,6 +301,22 @@ public static void SetClearTextButton(DependencyObject obj, bool value) obj.SetValue(ClearTextButtonProperty, value); } + /// + /// Gets the buttons placement variant. + /// + public static ButtonsPlacementVariant GetButtonsPlacement(DependencyObject d) + { + return (ButtonsPlacementVariant)d.GetValue(ButtonsPlacementProperty); + } + + /// + /// Sets the buttons placement variant. + /// + public static void SetButtonsPlacement(DependencyObject obj, ButtonsPlacementVariant value) + { + obj.SetValue(ButtonsPlacementProperty, value); + } + /// /// Gets the clear text button behavior. /// @@ -318,6 +335,8 @@ public static void SetIsClearTextButtonBehaviorEnabled(Button obj, bool value) obj.SetValue(IsClearTextButtonBehaviorEnabledProperty, value); } + + public static ICommand GetButtonCommand(DependencyObject d) { return (ICommand)d.GetValue(ButtonCommandProperty); diff --git a/MahApps.Metro/Controls/NumericUpDown.cs b/MahApps.Metro/Controls/NumericUpDown.cs index 81accc6c7d..f0a557a394 100644 --- a/MahApps.Metro/Controls/NumericUpDown.cs +++ b/MahApps.Metro/Controls/NumericUpDown.cs @@ -70,6 +70,12 @@ private static void IsReadOnlyPropertyChangedCallback(DependencyObject dependenc typeof(NumericUpDown), new FrameworkPropertyMetadata(default(double?), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged, CoerceValue)); + public static readonly DependencyProperty ButtonsPlacementProperty = DependencyProperty.Register( + "ButtonsPlacement", + typeof(ButtonsPlacementVariant), + typeof(NumericUpDown), + new FrameworkPropertyMetadata(ButtonsPlacementVariant.Right, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); + public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register( "Minimum", typeof(double), @@ -317,6 +323,15 @@ public double UpDownButtonsWidth set { SetValue(UpDownButtonsWidthProperty, value); } } + [Bindable(true)] + [Category("Appearance")] + [DefaultValue(ButtonsPlacementVariant.Right)] + public Controls.ButtonsPlacementVariant ButtonsPlacement + { + get { return (ButtonsPlacementVariant)GetValue(ButtonsPlacementProperty); } + set { SetValue(ButtonsPlacementProperty, value); } + } + [Bindable(true)] [Category("Behavior")] [DefaultValue(DefaultInterval)] @@ -855,7 +870,7 @@ private static void OnValueChanged(DependencyObject d, DependencyPropertyChanged numericUpDown.OnValueChanged((double?)e.OldValue, (double?)e.NewValue); } - private static bool ValidateDelay(object value) + private static bool ValidateDelay(object value) { return Convert.ToInt32(value) >= 0; } diff --git a/MahApps.Metro/MahApps.Metro.NET45.csproj b/MahApps.Metro/MahApps.Metro.NET45.csproj index 1df2e27d17..3a32ca25f8 100644 --- a/MahApps.Metro/MahApps.Metro.NET45.csproj +++ b/MahApps.Metro/MahApps.Metro.NET45.csproj @@ -130,6 +130,7 @@ + diff --git a/MahApps.Metro/MahApps.Metro.csproj b/MahApps.Metro/MahApps.Metro.csproj index bfb2fb1fe2..2e36e883ff 100644 --- a/MahApps.Metro/MahApps.Metro.csproj +++ b/MahApps.Metro/MahApps.Metro.csproj @@ -85,6 +85,7 @@ + diff --git a/MahApps.Metro/Styles/Controls.Expander.xaml b/MahApps.Metro/Styles/Controls.Expander.xaml index 44185ef0b3..b41c309348 100644 --- a/MahApps.Metro/Styles/Controls.Expander.xaml +++ b/MahApps.Metro/Styles/Controls.Expander.xaml @@ -352,8 +352,6 @@