Fix the right arrow button of CalculationResult not disappearing in some cases (#736)

This commit is contained in:
Rudy Huyn 2019-11-05 16:51:36 -08:00 committed by GitHub
parent 613aaebf6f
commit 8ba7234550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -87,6 +87,12 @@ void CalculationResult::OnApplyTemplate()
}
}
if (m_textBlock != nullptr && m_textBlockSizeChangedToken.Value != 0)
{
m_textBlock->SizeChanged -= m_textBlockSizeChangedToken;
m_textBlockSizeChangedToken.Value = 0;
}
if (m_scrollLeft != nullptr && m_scrollLeftClickToken.Value != 0)
{
m_scrollLeft->Click -= m_scrollLeftClickToken;
@ -128,6 +134,7 @@ void CalculationResult::OnApplyTemplate()
if (m_textBlock)
{
m_textBlock->Visibility = ::Visibility::Visible;
m_textBlockSizeChangedToken = m_textBlock->SizeChanged += ref new SizeChangedEventHandler(this, &CalculationResult::OnTextBlockSizeChanged);
}
}
UpdateVisualState();
@ -417,3 +424,8 @@ void CalculationResult::OnTextContainerOnViewChanged(Object ^ /*sender*/, Scroll
{
UpdateScrollButtons();
}
void CalculationResult::OnTextBlockSizeChanged(Object ^ /*sender*/, SizeChangedEventArgs ^ /*e*/)
{
UpdateScrollButtons();
}

View File

@ -56,6 +56,7 @@ namespace CalculatorApp
void OnMinFontSizePropertyChanged(double oldValue, double newValue);
void OnMaxFontSizePropertyChanged(double oldValue, double newValue);
void OnTextContainerSizeChanged(Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
void OnTextBlockSizeChanged(Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
void OnTextContainerLayoutUpdated(Object ^ sender, Object ^ e);
void OnTextContainerOnViewChanged(Object ^ sender, Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs ^ e);
void UpdateVisualState();
@ -82,6 +83,7 @@ namespace CalculatorApp
Windows::Foundation::EventRegistrationToken m_textContainerSizeChangedToken;
Windows::Foundation::EventRegistrationToken m_scrollRightClickToken;
Windows::Foundation::EventRegistrationToken m_scrollLeftClickToken;
Windows::Foundation::EventRegistrationToken m_textBlockSizeChangedToken;
};
}
}