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

TeachingTip: Fix bug where empty title/subtitle was not respected in ApplyTemplate leading to gap #3397

23 changes: 23 additions & 0 deletions dev/TeachingTip/APITests/TeachingTipTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,29 @@ public void PropagatePropertiesDown()
});
}

[TestMethod]
public void VerifySubTitleBlockVisibilityOnInitialUnset()
{
TeachingTip teachingTip = null;
RunOnUIThread.Execute(() =>
{
teachingTip = new TeachingTip();
teachingTip.IsOpen = true;
Content = teachingTip;
});

IdleSynchronizer.Wait();

RunOnUIThread.Execute(() =>
{
Verify.AreEqual("", teachingTip.Title);
Verify.AreEqual(Visibility.Collapsed,
TeachingTipTestHooks.GetTitleVisibility(teachingTip));
Verify.AreEqual("", teachingTip.Subtitle);
Verify.AreEqual(Visibility.Collapsed,
TeachingTipTestHooks.GetSubtitleVisibility(teachingTip));
});
}

[TestMethod]
public void TeachingTipHeroContentPlacementTest()
Expand Down
23 changes: 20 additions & 3 deletions dev/TeachingTip/TeachingTip.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "pch.h"
#include "pch.h"
#include "common.h"
#include "TeachingTip.h"
#include "RuntimeProfiler.h"
Expand Down Expand Up @@ -49,8 +49,25 @@ void TeachingTip::OnApplyTemplate()
m_closeButton.set(GetTemplateChildT<winrt::Button>(s_closeButtonName, controlProtected));
m_tailEdgeBorder.set(GetTemplateChildT<winrt::Grid>(s_tailEdgeBorderName, controlProtected));
m_tailPolygon.set(GetTemplateChildT<winrt::Polygon>(s_tailPolygonName, controlProtected));
m_titleTextBox.set(GetTemplateChildT<winrt::UIElement>(s_titleTextBoxName, controlProtected));
m_subtitleTextBox.set(GetTemplateChildT<winrt::UIElement>(s_subtitleTextBoxName, controlProtected));
[this](const winrt::UIElement textBlock)
{
m_titleTextBox.set(textBlock);
if (textBlock != nullptr)
{
ToggleVisibilityForEmptyContent(textBlock, Title());
}

}(GetTemplateChildT<winrt::UIElement>(s_titleTextBoxName, controlProtected));
[this](const winrt::UIElement textBlock)
{
m_subtitleTextBox.set(textBlock);
if (textBlock != nullptr)
{
ToggleVisibilityForEmptyContent(textBlock, Subtitle());
}

}(GetTemplateChildT<winrt::UIElement>(s_subtitleTextBoxName, controlProtected));


if (auto&& container = m_container.get())
{
Expand Down