mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-14 10:36:50 -07:00
Fix alignment of number pad buttons.
This commit is contained in:
parent
6ece807db8
commit
a5237d4ed6
4 changed files with 44 additions and 3 deletions
|
@ -727,7 +727,8 @@
|
|||
Grid.Row="2"
|
||||
Grid.RowSpan="4"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.ColumnSpan="4"
|
||||
ExtraColumns="1"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle18}"
|
||||
CurrentRadixType="{x:Bind Model.CurrentRadixType, Mode=OneWay}"/>
|
||||
</Grid>
|
||||
|
|
|
@ -1303,7 +1303,8 @@
|
|||
Grid.Row="4"
|
||||
Grid.RowSpan="4"
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.ColumnSpan="4"
|
||||
ExtraColumns="1"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
AutomationProperties.Name="{utils:ResourceString Name=NumberPad/[using:Windows.UI.Xaml.Automation]AutomationProperties/Name}"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}"/>
|
||||
|
|
|
@ -329,7 +329,8 @@
|
|||
Grid.Row="2"
|
||||
Grid.RowSpan="4"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="3"
|
||||
Grid.ColumnSpan="4"
|
||||
ExtraColumns="1"
|
||||
AutomationProperties.HeadingLevel="Level1"
|
||||
AutomationProperties.Name="{utils:ResourceString Name=NumberPad/[using:Windows.UI.Xaml.Automation]AutomationProperties/Name}"
|
||||
ButtonStyle="{StaticResource NumericButtonStyle24}"/>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using CalculatorApp.ViewModel.Common;
|
||||
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
|
@ -29,6 +30,20 @@ namespace CalculatorApp
|
|||
Num9Button.Content = localizationSettings.GetDigitSymbolFromEnUsDigit('9');
|
||||
}
|
||||
|
||||
// Extra empty columns to the right so that column widths are calculated consistently with the rest of the button panel.
|
||||
|
||||
public int ExtraColumns
|
||||
{
|
||||
get => (int)GetValue(ExtraColumnsProperty);
|
||||
set => SetValue(ExtraColumnsProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ExtraColumnsProperty =
|
||||
DependencyProperty.Register(nameof(ExtraColumns), typeof(int), typeof(NumberPad), new PropertyMetadata(0, (sender, args) =>
|
||||
{
|
||||
((NumberPad)sender).OnExtraColumnsPropertyChanged((int)args.OldValue, (int)args.NewValue);
|
||||
}));
|
||||
|
||||
public Windows.UI.Xaml.Style ButtonStyle
|
||||
{
|
||||
get => (Windows.UI.Xaml.Style)GetValue(ButtonStyleProperty);
|
||||
|
@ -67,6 +82,29 @@ namespace CalculatorApp
|
|||
}
|
||||
}
|
||||
|
||||
private void OnExtraColumnsPropertyChanged(int oldValue, int newValue)
|
||||
{
|
||||
if (newValue < 0)
|
||||
{
|
||||
throw new ArgumentException($"ExtraColumns of value {newValue} is smaller than 0.");
|
||||
}
|
||||
var columnDefinitions = Root.ColumnDefinitions;
|
||||
if (newValue > oldValue)
|
||||
{
|
||||
for (int i = oldValue; i < newValue; ++i)
|
||||
{
|
||||
columnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = oldValue; i > newValue; --i)
|
||||
{
|
||||
columnDefinitions.RemoveAt(columnDefinitions.Count - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCurrentRadixTypePropertyChanged(NumberBase oldValue, NumberBase newValue)
|
||||
{
|
||||
Num0Button.IsEnabled = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue