How to scroll in the tabs area in TabView in WinUI3 by using code

C CB 170 Reputation points
2024-07-05T08:19:01.0566667+00:00

There are many tabs in a TabView Control in WinUI3 App. I made a function: pin a selected tab to top. After set it to the top (meaning the first tab ), I make it be selected. Everything is ok, but the first selected tab may be hidden if I had previously chosen to set the tabs at the end to the top. So how to scroll the tab area in code?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
798 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,039 questions
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 12,726 Reputation points Microsoft Vendor
    2024-07-08T05:35:44.5533333+00:00

    Using FindChildren, it works for me.

    var list = new List<ScrollViewer>();
    FindChildren(list, sender);
    list[0].ChangeView(0,null,null);
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.