public static FabTabItem FindFabTabFromItem(this FabTabControl control, object item) { FabTabItem fabTab = item as FabTabItem; if (fabTab == null) { fabTab = control.ItemContainerGenerator.ContainerFromItem(item) as FabTabItem; } return(fabTab); }
public bool IsDraggable(UIElement dragElt) { if (dragElt is FabTabItem) { //I wonder if there are performance issues with making this call in a //potentially frequently-called method like this _tabControl = this.GetFabTabItemsParent(dragElt); if (_tabControl.AllowDragAndDropTabReordering) { return(true); } } return(false); }
void NoXamlWindow_Loaded(object sender, RoutedEventArgs e) { myTabControl = new FabTabControl(); FabTabItem tab1 = new FabTabItem(); tab1.Content = new SampleView(); tab1.Header = "Tab 1"; FabTabItem tab2 = new FabTabItem(); tab2.Content = new SampleView(); tab2.Header = "Tab 2"; myTabControl.Items.Add(tab1); myTabControl.Items.Add(tab2); grid.Children.Add(myTabControl); }
public DataObject GetDataObject(UIElement draggedElt) { if (draggedElt == null) { return(null); } if (_tabControl == null) { _tabControl = GetFabTabItemsParent(draggedElt); } if (_tabControl == null) { throw new Exception("Can't find parent FabTabControl for FabTabItem"); } FabTabItem fti = draggedElt as FabTabItem; DataObject obj = new DataObject("FabTabItem", _tabControl.ItemContainerGenerator.IndexFromContainer(fti).ToString()); return(obj); }
public DataObject GetDataObject(UIElement draggedElt) { if (draggedElt == null) { return null; } if (_tabControl == null) { _tabControl = GetFabTabItemsParent(draggedElt); } if (_tabControl == null) { throw new Exception("Can't find parent FabTabControl for FabTabItem"); } FabTabItem fti = draggedElt as FabTabItem; DataObject obj = new DataObject("FabTabItem", _tabControl.ItemContainerGenerator.IndexFromContainer(fti).ToString()); return obj; }
public void OnDropCompleted(IDataObject obj, UIElement sender) { //FabTabItem fabTabItem = _targetElt as FabTabItem; //FabTabControl fabTabControl = this.GetFabTabItemsParent(fabTabItem); FabTabItem dropTargetTabItem = sender as FabTabItem; FabTabControl fabTabControl = this.GetFabTabItemsParent(sender); int indexToInsertAt = fabTabControl.ItemContainerGenerator.IndexFromContainer(dropTargetTabItem); if (indexToInsertAt == -1) { throw new Exception("item not found"); } int index = ExtractElementIndex(obj); FabTabItem targetFabTabItem = fabTabControl.ItemContainerGenerator.ContainerFromIndex(index) as FabTabItem; if (fabTabControl.Items.Contains(targetFabTabItem)) { fabTabControl.Items.Remove(targetFabTabItem); //need a special case here because if there's only 2 items left, removing one //removes the contenttab and we have to account for that if (fabTabControl.Items.Count == 1 && indexToInsertAt == 2 && fabTabControl.ShowContentsTab) { fabTabControl.Items.Add(targetFabTabItem); } else { fabTabControl.Items.Insert(indexToInsertAt, targetFabTabItem); } } else if (fabTabControl.ItemsSource != null) { IList items = fabTabControl.ItemsSource as IList; if (items != null) { object content = targetFabTabItem.Content; fabTabControl.ItemsSource = null; items.Remove(content); items.Insert(indexToInsertAt, content); fabTabControl.ItemsSource = items; } } else { object content = targetFabTabItem.Content; fabTabControl.Items.Remove(content); //TODO, reduce the duplication with this if block and the one right above. if (fabTabControl.Items.Count == 1 && indexToInsertAt == 2 && fabTabControl.ShowContentsTab) { fabTabControl.Items.Add(content); } else { //removing the content and re-inserting it causes a new FabTabItem to be generated //therefore anybody subscribing to TabClosing events will no longer receive notifications. //This is only a problem for using Items collection with nonFabTabItems put into it //so that the ItemContainerGenerator itself has to create them. fabTabControl.Items.Insert(indexToInsertAt, content); } } fabTabControl.SelectedIndex = indexToInsertAt; }
public ExplorerControl(FabTabControl fabTab) { _fabTab = fabTab; InitializeComponent(); }
public bool IsDraggable(UIElement dragElt) { if (dragElt is FabTabItem ) { //I wonder if there are performance issues with making this call in a //potentially frequently-called method like this _tabControl = this.GetFabTabItemsParent(dragElt); if (_tabControl.AllowDragAndDropTabReordering) { return true; } } return false; }