/// <summary> /// Callback to handle tab closing. /// </summary> private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { //in here you can dispose stuff or cancel the close //here's your view model: var view = args.DragablzItem.DataContext as UserControl; if (view != null) { var viewModel = view.DataContext; Type viewModelType = viewModel.GetType(); MethodInfo methodInfo = viewModelType.GetMethod("DisposeEvents"); if (methodInfo != null) { methodInfo.Invoke(viewModel, null); } } var tabItem = args.DragablzItem; var tabControl = FindParent <TabControl>(tabItem); if (tabControl == null) { return; } IRegion region = RegionManager.GetObservableRegion(tabControl).Value; if (region == null) { return; } IViewsCollection collection = region.ActiveViews; object currentView = null; foreach (var v in collection) { currentView = v; } if (currentView != null) { PropertyInfo parameterInfo = currentView.GetType().GetProperty("Header"); if (parameterInfo != null) { string headerName = parameterInfo.GetValue(currentView, null) as string; string name = args.DragablzItem.Content as string; if (name != null) { if (headerName == args.DragablzItem.Content.ToString()) { RemoveItemFromRegion(currentView, region); } } } } //here's how you can cancel stuff: //args.Cancel(); }
private void SetViewInfo() { IViewsCollection views = _regionManager.Regions[this.PopWindowInfo.RegionName].ActiveViews; if (views.Count() > 0 && (views.ToList()[0] is FrameworkElement) && (views.ToList()[0] as FrameworkElement).DataContext is INavigationPage) { _currentView = (views.ToList()[0] as FrameworkElement).DataContext as INavigationPage; _currentView.PopWindowInfo = this.PopWindowInfo; this.CustomControl = _currentView.CreateCustomControl(); } }
private void OnActivateAddNewPatientModule() { IRegion region = _regionManager.Regions[RegionNames.CONTENT_REGION]; IViewsCollection activeViews = region.ActiveViews; if (region.ActiveViews.Any(x => x is ContentView)) { return; } else { region.ActiveViews.ForEach(x => region.Deactivate(x)); var view = region.Views.First(x => x is ContentView); region.Activate(view); } }
/// <summary> /// Handles the CollectionChanged event of the ActiveViews control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param> private void ActiveViews_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { IViewsCollection newviews = this.Region.ActiveViews; foreach (object view in this.Region.Views) { (view as Control).SetValue(DockingManager.StateProperty, DockState.Hidden); } foreach (object view in this.Region.ActiveViews) { if ((view as Control).Tag == null) { (view as Control).Tag = DockState.Dock; } (view as Control).SetValue(DockingManager.StateProperty, (view as Control).Tag); } }
/// <summary> /// Handles the CollectionChanged event of the ActiveViews control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param> private void ActiveViews_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { IViewsCollection newviews = this.Region.ActiveViews; foreach (object view in this.Region.Views) { (view as Control).SetValue(DockingManager.StateProperty, DockState.Hidden); } foreach (object view in this.Region.ActiveViews) { //if (!this.Region.ActiveViews.Contains(view)) //{ // (view as Control).SetValue(DockingManager.StateProperty, DockState.Hidden); //} //else { if ((view as Control).Tag == null) { (view as Control).Tag = DockState.Dock; } (view as Control).SetValue(DockingManager.StateProperty, (view as Control).Tag); } } //if (this.updatingActiveViewsInHostControlSelectionChanged) //{ // return; //} //if (e.Action == NotifyCollectionChangedAction.Add) //{ // if (this.hostControl.ActiveWindow != null // && this.hostControl.ActiveWindow != e.NewItems[0] // && this.Region.ActiveViews.Contains(this.hostControl.ActiveWindow)) // { // this.Region.Deactivate(this.hostControl.ActiveWindow); // } // this.hostControl.ActiveWindow = e.NewItems[0] as FrameworkElement; //} //else if (e.Action == NotifyCollectionChangedAction.Remove && // e.OldItems.Contains(this.hostControl.ActiveWindow)) //{ // this.hostControl.ActiveWindow = null; //} }