From 768854af32d27a4b7428aeb2f1aa7e87598d7802 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Sat, 21 Mar 2020 16:45:45 +0100 Subject: [PATCH] Numberbox header aligning (#2117) * Fix issue with header taking up space when not specified/null * Add NumberBox header test * Add log comments for test * Fix behavior of empty string * Update test --- dev/Generated/NumberBox.properties.cpp | 10 ++++- dev/Generated/NumberBox.properties.h | 4 ++ .../InteractionTests/NumberBoxTests.cs | 30 ++++++++++++++ dev/NumberBox/NumberBox.cpp | 41 +++++++++++++++++++ dev/NumberBox/NumberBox.h | 2 + dev/NumberBox/NumberBox.idl | 1 + dev/NumberBox/NumberBox.xaml | 4 +- dev/NumberBox/TestUI/NumberBoxPage.xaml | 8 ++++ dev/NumberBox/TestUI/NumberBoxPage.xaml.cs | 24 +++++++++++ 9 files changed, 122 insertions(+), 2 deletions(-) diff --git a/dev/Generated/NumberBox.properties.cpp b/dev/Generated/NumberBox.properties.cpp index 01df4ba7c8..323b3d557a 100644 --- a/dev/Generated/NumberBox.properties.cpp +++ b/dev/Generated/NumberBox.properties.cpp @@ -72,7 +72,7 @@ void NumberBoxProperties::EnsureProperties() winrt::name_of(), false /* isAttached */, ValueHelper::BoxedDefaultValue(), - nullptr); + winrt::PropertyChangedCallback(&OnHeaderPropertyChanged)); } if (!s_HeaderTemplateProperty) { @@ -275,6 +275,14 @@ void NumberBoxProperties::ClearProperties() s_ValueProperty = nullptr; } +void NumberBoxProperties::OnHeaderPropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args) +{ + auto owner = sender.as(); + winrt::get_self(owner)->OnHeaderPropertyChanged(args); +} + void NumberBoxProperties::OnIsWrapEnabledPropertyChanged( winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args) diff --git a/dev/Generated/NumberBox.properties.h b/dev/Generated/NumberBox.properties.h index fb9c4757db..ed33776413 100644 --- a/dev/Generated/NumberBox.properties.h +++ b/dev/Generated/NumberBox.properties.h @@ -114,6 +114,10 @@ class NumberBoxProperties static void EnsureProperties(); static void ClearProperties(); + static void OnHeaderPropertyChanged( + winrt::DependencyObject const& sender, + winrt::DependencyPropertyChangedEventArgs const& args); + static void OnIsWrapEnabledPropertyChanged( winrt::DependencyObject const& sender, winrt::DependencyPropertyChangedEventArgs const& args); diff --git a/dev/NumberBox/InteractionTests/NumberBoxTests.cs b/dev/NumberBox/InteractionTests/NumberBoxTests.cs index c0e0e8baf4..2941c6c497 100644 --- a/dev/NumberBox/InteractionTests/NumberBoxTests.cs +++ b/dev/NumberBox/InteractionTests/NumberBoxTests.cs @@ -533,6 +533,36 @@ public void BasicExpressionTest() } } + [TestMethod] + public void VerifyNumberBoxHeaderBehavior() + { + using (var setup = new TestSetupHelper("NumberBox Tests")) + { + var toggleHeaderButton = FindElement.ByName