Created
October 6, 2015 18:05
-
-
Save KennethanCeyer/08304f69cf513e898fd3 to your computer and use it in GitHub Desktop.
WPF TabControl Selection Changed : The solution that problem calling those event infinitely.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very helpful. Thanks for posting this.