UWP TabView 以编程方式更改选项卡

UWP TabView change tab programatically

如何以编程方式更改选项卡视图选项卡?例如,用户打开了第二个标签,我想将标签更改为第一个。

根据this note

您可以通过以下方式完成:

// Only select the tab if it is in the list
if (tabToSelect < TabRoot.TabItems.Count)
{
    TabRoot.SelectedIndex = tabToSelect;
}

在 C++ 中,您必须按以下方式进行操作:

int index = 1;
if (tabcontrol->TabItems->Size > index)
{
    tabcontrol->SelectedIndex = index;
}