private void DoPageTapped(PageDockAdapterControl vb) { if (vb == null) { return; } var page = vb.GetPage(); //Page page = vb.Child as Page; if (page == null) { return; } if (DockParent == null) { return; } // It's critical to remove the page from the viewbox; otherwise when the DockParent aka main page tries to // display the page, it won't work. vb.RemovePage(page); // And reset it for use! DockParent.DisplayFromDock(page); }
public void DeletePage(PageDockAdapterControl page) { uiDock.Items.Remove(page); if (uiDock.Items.Count == 0) { this.Visibility = Visibility.Collapsed; } }
public static PageDockAdapterControl MakeAdapter(Page page, IDeletePage dp) { if (!(page is HasId)) { return(null); } // Gotta dock it for the first time var vb = new PageDockAdapterControl(); vb.SetPage(page); vb.IsTapEnabled = true; vb.Tag = (page as HasId)?.GetId(); vb.DeletePage = dp; // Set up the page to be untappable page.IsTapEnabled = false; page.IsEnabled = false; return(vb); }
// Each Page is wrapped in a ViewBox zooming viewer /// <summary> /// Adds a page to the dock. It might already have a spot in the dock. /// Each page is wrapped in a ViewBox zooming viewer and added to the uiDock panel /// The dock is made visible. /// </summary> /// <param name="page"></param> public void AddPage(Page page) { if (!(page is HasId)) { return; } this.Visibility = Visibility.Visible; var id = (page as HasId).GetId(); var index = FindPage(id); if (index >= 0) { var vb = uiDock.Items[index] as PageDockAdapterControl; // Regardless of whether the child was already set, set it to the page. // We might set the child to be, e.g. a little icon or something. vb.SetPage(page); } else { // Gotta dock it for the first time var vb = PageDockAdapterControl.MakeAdapter(page, this); uiDock.Items.Insert(0, vb); //Always put as the first item? } }