-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
Showing
9 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
#include "Utils.h" | ||
#include "winnls.h" | ||
|
||
static constexpr wstring_view c_numberBoxHeaderName{ L"HeaderContentPresenter"sv }; | ||
static constexpr wstring_view c_numberBoxDownButtonName{ L"DownSpinButton"sv }; | ||
static constexpr wstring_view c_numberBoxUpButtonName{ L"UpSpinButton"sv }; | ||
static constexpr wstring_view c_numberBoxTextBoxName{ L"InputBox"sv }; | ||
|
@@ -135,6 +136,12 @@ void NumberBox::OnApplyTemplate() | |
} | ||
} | ||
|
||
if (const auto headerPresenter = GetTemplateChildT<winrt::ContentPresenter>(c_numberBoxHeaderName, controlProtected)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
marcelwgn
Author
Collaborator
|
||
{ | ||
// Set presenter to enable lightweight styling of the headers margin | ||
m_headerPresenter.set(headerPresenter); | ||
} | ||
|
||
m_textBox.set([this, controlProtected]() { | ||
const auto textBox = GetTemplateChildT<winrt::TextBox>(c_numberBoxTextBoxName, controlProtected); | ||
if (textBox) | ||
|
@@ -298,6 +305,40 @@ void NumberBox::UpdateValueToText() | |
} | ||
} | ||
|
||
void NumberBox::OnHeaderPropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) | ||
This comment has been minimized.
Sorry, something went wrong.
Kinnara
Contributor
|
||
{ | ||
// To enable lightweight styling, collapse header presenter if there is no header specified | ||
if (const auto headerPresenter = m_headerPresenter.get()) | ||
{ | ||
if (const auto header = Header()) | ||
{ | ||
// Check if header is string or not | ||
if (const auto headerAsString = Header().try_as<winrt::IReference<winrt::hstring>>()) | ||
{ | ||
if (headerAsString.Value().empty()) | ||
{ | ||
// String is the empty string, hide presenter | ||
headerPresenter.Visibility(winrt::Visibility::Collapsed); | ||
} | ||
else | ||
{ | ||
// String is not an empty string | ||
headerPresenter.Visibility(winrt::Visibility::Visible); | ||
} | ||
} | ||
else | ||
{ | ||
// Header is not a string, so let's show header presenter | ||
headerPresenter.Visibility(winrt::Visibility::Visible); | ||
} | ||
} | ||
else | ||
{ | ||
headerPresenter.Visibility(winrt::Visibility::Collapsed); | ||
} | ||
} | ||
} | ||
|
||
void NumberBox::OnValidationModePropertyChanged(const winrt::DependencyPropertyChangedEventArgs& args) | ||
{ | ||
ValidateInput(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There seem to be a couple issues here:
GetTemplateChild
regardless of whether the header should be visible, will always realize the header presenter and make thex:DeferLoadStrategy="Lazy"
in the template useless.OnApplyTemplate
, it won't be visible because whenOnHeaderPropertyChanged
was calledm_headerPresenter
had not been set yet.