Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions MahApps.Metro/Controls/DataGridNumericUpDownColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class DataGridNumericUpDownColumn : DataGridBoundColumn
private double interval = (double)NumericUpDown.IntervalProperty.DefaultMetadata.DefaultValue;
private string stringFormat = (string)NumericUpDown.StringFormatProperty.DefaultMetadata.DefaultValue;
private bool hideUpDownButtons = (bool)NumericUpDown.HideUpDownButtonsProperty.DefaultMetadata.DefaultValue;
private double upDownButtonsWidth = (double)NumericUpDown.UpDownButtonsWidthProperty.DefaultMetadata.DefaultValue;
private Binding foregroundBinding;

static DataGridNumericUpDownColumn()
Expand Down Expand Up @@ -148,6 +149,7 @@ private NumericUpDown GenerateNumericUpDown(bool isEditing, DataGridCell cell)
numericUpDown.InterceptMouseWheel = true;
numericUpDown.Speedup = true;
numericUpDown.HideUpDownButtons = HideUpDownButtons;
numericUpDown.UpDownButtonsWidth = UpDownButtonsWidth;

return numericUpDown;
}
Expand Down Expand Up @@ -192,5 +194,11 @@ public bool HideUpDownButtons
get { return hideUpDownButtons; }
set { hideUpDownButtons = value; }
}

public double UpDownButtonsWidth
{
get { return upDownButtonsWidth; }
set { upDownButtonsWidth = value; }
}
}
}
19 changes: 18 additions & 1 deletion MahApps.Metro/Controls/NumericUpDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ private static void IsReadOnlyPropertyChangedCallback(DependencyObject dependenc
typeof(NumericUpDown),
new PropertyMetadata(default(bool)));

public static readonly DependencyProperty UpDownButtonsWidthProperty = DependencyProperty.Register(
"UpDownButtonsWidth",
typeof(double),
typeof(NumericUpDown),
new PropertyMetadata(20d));

public static readonly DependencyProperty InterceptManualEnterProperty = DependencyProperty.Register(
"InterceptManualEnter",
typeof(bool),
Expand Down Expand Up @@ -157,6 +163,7 @@ static NumericUpDown()
HorizontalContentAlignmentProperty.OverrideMetadata(typeof(NumericUpDown), new FrameworkPropertyMetadata(HorizontalAlignment.Right));

EventManager.RegisterClassHandler(typeof(NumericUpDown), UIElement.GotFocusEvent, new RoutedEventHandler(OnGotFocus));

}

public event RoutedPropertyChangedEventHandler<double?> ValueChanged
Expand Down Expand Up @@ -301,6 +308,15 @@ public bool HideUpDownButtons
set { SetValue(HideUpDownButtonsProperty, value); }
}

[Bindable(true)]
[Category("Appearance")]
[DefaultValue(20d)]
public double UpDownButtonsWidth
{
get { return (double)GetValue(UpDownButtonsWidthProperty); }
set { SetValue(UpDownButtonsWidthProperty, value); }
}

[Bindable(true)]
[Category("Behavior")]
[DefaultValue(DefaultInterval)]
Expand Down Expand Up @@ -426,6 +442,7 @@ private static void OnGotFocus(object sender, RoutedEventArgs e)
}
}
}

}

/// <summary>
Expand All @@ -438,7 +455,7 @@ public override void OnApplyTemplate()

_repeatUp = GetTemplateChild(ElementNumericUp) as RepeatButton;
_repeatDown = GetTemplateChild(ElementNumericDown) as RepeatButton;

_valueTextBox = GetTemplateChild(ElementTextBox) as TextBox;

if (_repeatUp == null ||
Expand Down
11 changes: 7 additions & 4 deletions MahApps.Metro/Themes/NumericUpDown.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition x:Name="PART_NumericUpColumn"
Width="20" />
Width="{TemplateBinding UpDownButtonsWidth}" />
<ColumnDefinition x:Name="PART_NumericDownColumn"
Width="20" />
Width="{TemplateBinding UpDownButtonsWidth}" />
</Grid.ColumnDefinitions>

<TextBox x:Name="PART_TextBox"
Expand All @@ -91,7 +91,8 @@
Delay="{TemplateBinding Delay}"
Foreground="{TemplateBinding Foreground}"
Style="{DynamicResource ChromelessButtonStyle}"
IsTabStop="False">
IsTabStop="False"
Width="{TemplateBinding UpDownButtonsWidth}">
<Path x:Name="PolygonUp"
Width="14"
Height="14"
Expand All @@ -106,7 +107,8 @@
Delay="{TemplateBinding Delay}"
Style="{DynamicResource ChromelessButtonStyle}"
Foreground="{TemplateBinding Foreground}"
IsTabStop="False">
IsTabStop="False"
Width="{TemplateBinding UpDownButtonsWidth}">
<Path x:Name="PolygonDown"
Width="14"
Height="3"
Expand Down Expand Up @@ -201,6 +203,7 @@
Property="Width"
Value="0" />
</Trigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Expand Down