Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NumericUpDown): TextAlignment #12368

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
15 changes: 15 additions & 0 deletions src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public class NumericUpDown : TemplatedControl
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty =
ContentControl.VerticalContentAlignmentProperty.AddOwner<NumericUpDown>();

/// <summary>
/// Defines the <see cref="TextAlignment"/> property
/// </summary>
public static readonly StyledProperty<Media.TextAlignment> TextAlignmentProperty =
TextBox.TextAlignmentProperty.AddOwner<NumericUpDown>();

private IDisposable? _textBoxTextChangedSubscription;

private bool _internalValueSet;
Expand Down Expand Up @@ -299,6 +305,15 @@ public VerticalAlignment VerticalContentAlignment
set => SetValue(VerticalContentAlignmentProperty, value);
}

/// <summary>
/// Gets or sets the <see cref="Media.TextAlignment"/> of the <see cref="NumericUpDown"/>
/// </summary>
public Media.TextAlignment TextAlignment
{
get => GetValue(TextAlignmentProperty);
set => SetValue(TextAlignmentProperty, value);
}

/// <summary>
/// Initializes new instance of <see cref="NumericUpDown"/> class.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/Avalonia.Themes.Fluent/Controls/NumericUpDown.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Text="{TemplateBinding Text}"
TextAlignment="{TemplateBinding TextAlignment}"
AcceptsReturn="False"
TextWrapping="NoWrap" />
</ButtonSpinner>
Expand Down
1 change: 1 addition & 0 deletions src/Avalonia.Themes.Simple/Controls/NumericUpDown.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
IsReadOnly="{TemplateBinding IsReadOnly}"
Text="{TemplateBinding Text}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="NoWrap"
Watermark="{TemplateBinding Watermark}" />
</ButtonSpinner>
Expand Down