Skip to content

Commit

Permalink
TabView: Fix for terminal handling scrollviewer load issue (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
teaP authored and jevansaks committed Sep 17, 2019
1 parent 44a2d6f commit 96b64c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
16 changes: 11 additions & 5 deletions dev/TabView/TabView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,20 @@ void TabView::OnListViewLoaded(const winrt::IInspectable&, const winrt::RoutedEv
SelectedIndex(listView.SelectedIndex());
SelectedItem(listView.SelectedItem());

m_scrollViewer.set([this, listView]() {
auto scrollViewer = SharedHelpers::FindInVisualTreeByName(listView, L"ScrollViewer").as<winrt::FxScrollViewer>();
if (scrollViewer)
auto scrollViewer = SharedHelpers::FindInVisualTreeByName(listView, L"ScrollViewer").as<winrt::FxScrollViewer>();
m_scrollViewer.set(scrollViewer);
if (scrollViewer)
{
if (SharedHelpers::IsIsLoadedAvailable() && scrollViewer.IsLoaded())
{
// This scenario occurs reliably for Terminal in XAML islands
OnScrollViewerLoaded(nullptr, nullptr);
}
else
{
m_scrollViewerLoadedRevoker = scrollViewer.Loaded(winrt::auto_revoke, { this, &TabView::OnScrollViewerLoaded });
}
return scrollViewer;
}());
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions dev/dll/SharedHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ bool SharedHelpers::IsThemeShadowAvailable()
return s_isThemeShadowAvailable;
}

bool SharedHelpers::IsIsLoadedAvailable()
{
static bool s_isAvailable =
IsRS5OrHigher() ||
winrt::ApiInformation::IsPropertyPresent(L"Windows.UI.Xaml.FrameworkElement", L"IsLoaded");
return s_isAvailable;
}

template <uint16_t APIVersion> bool SharedHelpers::IsAPIContractVxAvailable()
{
static bool isAPIContractVxAvailableInitialized = false;
Expand Down
2 changes: 2 additions & 0 deletions dev/inc/SharedHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class SharedHelpers

static bool IsThemeShadowAvailable();

static bool IsIsLoadedAvailable();

// Actual OS version checks
static bool IsAPIContractV9Available(); // 19H2
static bool IsAPIContractV8Available(); // 19H1
Expand Down

0 comments on commit 96b64c0

Please sign in to comment.