Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KennethanCeyer/08304f69cf513e898fd3 to your computer and use it in GitHub Desktop.
Save KennethanCeyer/08304f69cf513e898fd3 to your computer and use it in GitHub Desktop.
WPF TabControl Selection Changed : The solution that problem calling those event infinitely.
private void MainTabChanged(object sender, SelectionChangedEventArgs e)
{
int tabItem = ((sender as TabControl)).SelectedIndex;
if (e.Source is TabControl) // This is a soultion of those problem.
{
switch (tabItem)
{
case 0: // Chatting
Debug.WriteLine("Tab: Chatting");
if (MainChatList.Items.Count > 0)
{
MainChatList.SelectedIndex = MainChatList.Items.Count - 1;
MainChatList.ScrollIntoView(MainChatList.Items[MainChatList.Items.Count - 1]);
}
break;
case 1: // Users
Debug.WriteLine("Tab: Users");
break;
case 2: // Friends
Debug.WriteLine("Tab: Friends");
this.OnFriendTabActive();
break;
default:
Debug.WriteLine("Tab: " + tabItem);
break;
}
}
}
@ccunning2
Copy link

This is very helpful. Thanks for posting this.

@roboticsware
Copy link

Very helpful, too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment