понедельник, 1 июня 2020 г.

Wpf TabItem Events

https://stackoverflow.com/questions/8172077/tabchanged-event-of-tabcontrol-in-wpf/39017978

https://stackoverflow.com/questions/8172077/tabchanged-event-of-tabcontrol-in-wpf

https://stackoverflow.com/questions/43351422/event-before-user-changes-tabitem


https://stackoverflow.com/questions/8172077/tabchanged-event-of-tabcontrol-in-wpf/39017978

https://stackoverflow.com/questions/3659858/in-c-sharp-wpf-why-is-my-tabcontrols-selectionchanged-event-firing-too-often

     private void tabControlName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.Source is TabControl) //if this event fired from TabControl then enter
            {
                if (tabItemName.IsSelected)
                {
                    //Do your job here
                }
            }
        }
private void Window_Loaded(object sender, RoutedEventArgs e)
{
  ItemCollection view = tabControl.Items;
  view.CurrentChanged += new EventHandler(view_CurrentChanged);
}

void view_CurrentChanged(object sender, EventArgs e)
{
  throw new NotImplementedException();
}
3.
<TabControl SelectionChanged="OnTabItemChanged">
    <TabItem Name="MainTap" Header="Dashboard"></TabItem
</TabControl>
private async void OnTabItemChanged(object sender, SelectionChangedEventArgs e)
{

    TabControl tabControl = sender as TabControl; // e.Source could have been used instead of sender as well
    TabItem item = tabControl.SelectedValue as TabItem;
    if (item.Name == "MainTap")
    {
        Debug.WriteLine(item.Name);
    }
}

In the OnSelectedChanged handler,

if (Equals(sender, e.OriginalSource)) 

{ /* do the work */ } 

then all child events will not enter the conditional block

Комментариев нет:

Отправить комментарий