private void OnSelectedContentChanged(TabbedLayout o, AvaloniaPropertyChangedEventArgs e) { TabbedLayoutItem oldTabItem = GetTabbedLayoutItem(e.OldValue); if (oldTabItem != null) { oldTabItem.IsSelected = false; } if (e.NewValue == null) { return; } TabbedLayoutItem tabItem = GetTabbedLayoutItem(e.NewValue); if (tabItem != null) { if (tabItem.ClosePropertyTabCommand == null) { tabItem.ClosePropertyTabCommand = ClosePropertyTabCommand; } tabItem.IsSelected = true; } }
private TabbedLayoutItem GetTabbedLayoutItem(object item) { TabbedLayoutItem tabItem = item as TabbedLayoutItem; if (tabItem == null) { tabItem = (item as IControl)?.Parent as TabbedLayoutItem; } return(tabItem); }