diff --git a/dev/Generated/NumberBox.properties.cpp b/dev/Generated/NumberBox.properties.cpp index 4e8424810a..f5a38d47a2 100644 --- a/dev/Generated/NumberBox.properties.cpp +++ b/dev/Generated/NumberBox.properties.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. // DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen @@ -29,6 +29,7 @@ GlobalDependencyProperty NumberBoxProperties::s_SelectionHighlightColorProperty{ GlobalDependencyProperty NumberBoxProperties::s_SmallChangeProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_SpinButtonPlacementModeProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_TextProperty{ nullptr }; +GlobalDependencyProperty NumberBoxProperties::s_TextAlignmentProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_TextReadingOrderProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_ValidationModeProperty{ nullptr }; GlobalDependencyProperty NumberBoxProperties::s_ValueProperty{ nullptr }; @@ -217,6 +218,17 @@ void NumberBoxProperties::EnsureProperties() ValueHelper::BoxedDefaultValue(), winrt::PropertyChangedCallback(&OnTextPropertyChanged)); } + if (!s_TextAlignmentProperty) + { + s_TextAlignmentProperty = + InitializeDependencyProperty( + L"TextAlignment", + winrt::name_of(), + winrt::name_of(), + false /* isAttached */, + ValueHelper::BoxValueIfNecessary(winrt::TextAlignment::Left), + nullptr); + } if (!s_TextReadingOrderProperty) { s_TextReadingOrderProperty = @@ -270,6 +282,7 @@ void NumberBoxProperties::ClearProperties() s_SmallChangeProperty = nullptr; s_SpinButtonPlacementModeProperty = nullptr; s_TextProperty = nullptr; + s_TextAlignmentProperty = nullptr; s_TextReadingOrderProperty = nullptr; s_ValidationModeProperty = nullptr; s_ValueProperty = nullptr; @@ -583,6 +596,19 @@ winrt::hstring NumberBoxProperties::Text() return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_TextProperty)); } +void NumberBoxProperties::TextAlignment(winrt::TextAlignment const& value) +{ + [[gsl::suppress(con)]] + { + static_cast(this)->SetValue(s_TextAlignmentProperty, ValueHelper::BoxValueIfNecessary(value)); + } +} + +winrt::TextAlignment NumberBoxProperties::TextAlignment() +{ + return ValueHelper::CastOrUnbox(static_cast(this)->GetValue(s_TextAlignmentProperty)); +} + void NumberBoxProperties::TextReadingOrder(winrt::TextReadingOrder const& value) { [[gsl::suppress(con)]] diff --git a/dev/Generated/NumberBox.properties.h b/dev/Generated/NumberBox.properties.h index 8beb3a75ba..c4fee4bc86 100644 --- a/dev/Generated/NumberBox.properties.h +++ b/dev/Generated/NumberBox.properties.h @@ -57,6 +57,9 @@ class NumberBoxProperties void Text(winrt::hstring const& value); winrt::hstring Text(); + void TextAlignment(winrt::TextAlignment const& value); + winrt::TextAlignment TextAlignment(); + void TextReadingOrder(winrt::TextReadingOrder const& value); winrt::TextReadingOrder TextReadingOrder(); @@ -82,6 +85,7 @@ class NumberBoxProperties static winrt::DependencyProperty SmallChangeProperty() { return s_SmallChangeProperty; } static winrt::DependencyProperty SpinButtonPlacementModeProperty() { return s_SpinButtonPlacementModeProperty; } static winrt::DependencyProperty TextProperty() { return s_TextProperty; } + static winrt::DependencyProperty TextAlignmentProperty() { return s_TextAlignmentProperty; } static winrt::DependencyProperty TextReadingOrderProperty() { return s_TextReadingOrderProperty; } static winrt::DependencyProperty ValidationModeProperty() { return s_ValidationModeProperty; } static winrt::DependencyProperty ValueProperty() { return s_ValueProperty; } @@ -102,6 +106,7 @@ class NumberBoxProperties static GlobalDependencyProperty s_SmallChangeProperty; static GlobalDependencyProperty s_SpinButtonPlacementModeProperty; static GlobalDependencyProperty s_TextProperty; + static GlobalDependencyProperty s_TextAlignmentProperty; static GlobalDependencyProperty s_TextReadingOrderProperty; static GlobalDependencyProperty s_ValidationModeProperty; static GlobalDependencyProperty s_ValueProperty; diff --git a/dev/NumberBox/APITests/NumberBoxTests.cs b/dev/NumberBox/APITests/NumberBoxTests.cs index f42ad787fa..ee4ea1c3a9 100644 --- a/dev/NumberBox/APITests/NumberBoxTests.cs +++ b/dev/NumberBox/APITests/NumberBoxTests.cs @@ -25,6 +25,26 @@ namespace Windows.UI.Xaml.Tests.MUXControls.ApiTests [TestClass] public class NumberBoxTests : ApiTestBase { + [TestMethod] + public void VerifyTextAlignmentPropogates() + { + var numberBox = SetupNumberBox(); + TextBox textBox = null; + + RunOnUIThread.Execute(() => + { + Content.UpdateLayout(); + + textBox = TestUtilities.FindDescendents(numberBox).Where(e => e.Name == "InputBox").Single(); + Verify.AreEqual(TextAlignment.Left, textBox.TextAlignment, "The default TextAlignment should be left."); + + numberBox.TextAlignment = TextAlignment.Right; + Content.UpdateLayout(); + + Verify.AreEqual(TextAlignment.Right, textBox.TextAlignment, "The TextAlignment should have been updated to Right."); + }); + } + [TestMethod] public void VerifyNumberBoxCornerRadius() { diff --git a/dev/NumberBox/NumberBox.idl b/dev/NumberBox/NumberBox.idl index 6219149d03..4fda3b54e3 100644 --- a/dev/NumberBox/NumberBox.idl +++ b/dev/NumberBox/NumberBox.idl @@ -60,6 +60,13 @@ unsealed runtimeclass NumberBox : Windows.UI.Xaml.Controls.Control String PlaceholderText; Windows.UI.Xaml.Controls.Primitives.FlyoutBase SelectionFlyout; Windows.UI.Xaml.Media.SolidColorBrush SelectionHighlightColor; + + [WUXC_VERSION_PREVIEW] + { + [MUX_DEFAULT_VALUE("winrt::TextAlignment::Left")] + Windows.UI.Xaml.TextAlignment TextAlignment; + } + Windows.UI.Xaml.TextReadingOrder TextReadingOrder; Boolean PreventKeyboardDisplayOnProgrammaticFocus; Object Description; @@ -98,6 +105,12 @@ unsealed runtimeclass NumberBox : Windows.UI.Xaml.Controls.Control static Windows.UI.Xaml.DependencyProperty PlaceholderTextProperty{ get; }; static Windows.UI.Xaml.DependencyProperty SelectionFlyoutProperty{ get; }; static Windows.UI.Xaml.DependencyProperty SelectionHighlightColorProperty{ get; }; + + [WUXC_VERSION_PREVIEW] + { + static Windows.UI.Xaml.DependencyProperty TextAlignmentProperty{ get; }; + } + static Windows.UI.Xaml.DependencyProperty TextReadingOrderProperty{ get; }; static Windows.UI.Xaml.DependencyProperty PreventKeyboardDisplayOnProgrammaticFocusProperty{ get; }; static Windows.UI.Xaml.DependencyProperty DescriptionProperty{ get; }; diff --git a/dev/NumberBox/NumberBox.xaml b/dev/NumberBox/NumberBox.xaml index 48311e556f..92af5aefc6 100644 --- a/dev/NumberBox/NumberBox.xaml +++ b/dev/NumberBox/NumberBox.xaml @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + @@ -93,7 +93,7 @@ - + @@ -125,6 +125,7 @@ FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" FontFamily="{TemplateBinding FontFamily}" + TextAlignment="{TemplateBinding TextAlignment}" contract7Present:CornerRadius="{TemplateBinding CornerRadius}" /> + + + + + + + diff --git a/dev/NumberBox/TestUI/NumberBoxPage.xaml.cs b/dev/NumberBox/TestUI/NumberBoxPage.xaml.cs index f6dd781dc0..f50ec8785b 100644 --- a/dev/NumberBox/TestUI/NumberBoxPage.xaml.cs +++ b/dev/NumberBox/TestUI/NumberBoxPage.xaml.cs @@ -46,6 +46,25 @@ private void SpinMode_Changed(object sender, RoutedEventArgs e) } } + private void TextAlignment_Changed(object sender, RoutedEventArgs e) + { + if (TestNumberBox != null) + { + if (TextAlignmentComboBox.SelectedIndex == 0) + { + TestNumberBox.TextAlignment = TextAlignment.Left; + } + else if (TextAlignmentComboBox.SelectedIndex == 1) + { + TestNumberBox.TextAlignment = TextAlignment.Center; + } + else if (TextAlignmentComboBox.SelectedIndex == 2) + { + TestNumberBox.TextAlignment = TextAlignment.Right; + } + } + } + private void Validation_Changed(object sender, RoutedEventArgs e) { if (TestNumberBox != null)