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

[UWP Renderer] Do not wrap textblock in ComboBoxItem for compact choiceset #8221

Merged
merged 4 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 1 addition & 5 deletions source/uwp/Renderer/lib/AdaptiveChoiceSetInputRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,12 @@ namespace winrt::AdaptiveCards::Rendering::Uwp::implementation
{
auto title = adaptiveChoiceInput.Title();

winrt::ComboBoxItem comboBoxItem{};

XamlHelpers::SetContent(comboBoxItem, title, wrap);

if (values.size() == 1 && IsChoiceSelected(values, adaptiveChoiceInput))
{
// If multiple values are specified, no option is selected
selectedIndex = currentIndex;
}
items.Append(comboBoxItem);
items.Append(XamlHelpers::CreateTextBlockWithContent(title, wrap));
currentIndex++;
}

Expand Down
12 changes: 12 additions & 0 deletions source/uwp/Renderer/lib/XamlHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ namespace AdaptiveCards::Rendering::Uwp::XamlHelpers
columnDefinition.Width(CalculateColumnWidth(true, false, false, isWidthUnset, pixelWidth, width));
}

winrt::TextBlock CreateTextBlockWithContent(winrt::hstring const& contentString, bool wrap)
{
winrt::TextBlock content{};
content.Text(contentString);
if (wrap)
{
content.TextWrapping(winrt::TextWrapping::WrapWholeWords);
}

return content;
}

winrt::Image CreateBackgroundImage(winrt::AdaptiveRenderContext const& renderContext, winrt::hstring const& url)
{
try
Expand Down
11 changes: 3 additions & 8 deletions source/uwp/Renderer/lib/XamlHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ namespace AdaptiveCards::Rendering::Uwp::XamlHelpers
return GetValueFromRef(toggleButton.IsChecked(), false);
}

winrt::TextBlock CreateTextBlockWithContent(winrt::hstring const& contentString, bool wrap);

template<typename T> void SetContent(T const& item, winrt::hstring const& contentString)
{
SetContent(item, contentString, false /* wrap */);
Expand All @@ -70,14 +72,7 @@ namespace AdaptiveCards::Rendering::Uwp::XamlHelpers
{
if (const auto contentControl = item.try_as<winrt::ContentControl>())
{
winrt::TextBlock content{};
content.Text(contentString);

if (wrap)
{
content.TextWrapping(winrt::TextWrapping::WrapWholeWords);
}
contentControl.Content(content);
contentControl.Content(CreateTextBlockWithContent(contentString, wrap));
}
}

Expand Down