private void ShowViewEventHandler(ShowViewEventArgs showView) { var mainRegion = _regionManager.Regions[Regions.MainContentRegion]; var viewExists = mainRegion.Views.FirstOrDefault(p => ((RadDocumentPane)p).Tag.ToString() == showView.Id); RadDocumentPane radDocumentPane = null; if (viewExists == null) { var childScope = _container.CreateChildContainer(); var view = childScope.Resolve(GetViewClassType(showView.ViewIdentifier)); var viewModel = childScope.Resolve(GetViewModelClassType(showView.ViewIdentifier)); radDocumentPane = new RadDocumentPane(); radDocumentPane.DataContext = viewModel; radDocumentPane.Content = view; if (radDocumentPane.Content is MyViewBase @base) { @base.ViewContainer = childScope; } radDocumentPane.Tag = showView.Id; radDocumentPane.HeaderTemplate = Application.Current.FindResource("RadDocumentPaneHeaderTemplate") as DataTemplate; var myBinding = new Binding(); myBinding.Source = (radDocumentPane.Content as FrameworkElement).DataContext; BindingOperations.SetBinding(radDocumentPane, HeaderedContentControl.HeaderProperty, myBinding); mainRegion.Add(radDocumentPane); } else { radDocumentPane = viewExists as RadDocumentPane; } radDocumentPane.IsActive = true; radDocumentPane.IsHidden = false; mainRegion.Activate(radDocumentPane); }
protected void ShowView(string viewIdentifier) { var showViewEvent = _eventAggregator.GetEvent <ShowViewEvent>(); var showViewEventArgs = new ShowViewEventArgs(); showViewEventArgs.Id = viewIdentifier; showViewEventArgs.ViewIdentifier = viewIdentifier; showViewEvent.Publish(showViewEventArgs); }
private void CloseViewEventHandler(ShowViewEventArgs closeView) { var mainRegion = _regionManager.Regions[Regions.MainContentRegion]; var viewExists = mainRegion.Views.FirstOrDefault(p => ((RadDocumentPane)p).Tag.ToString() == closeView.Id); if (viewExists != null) { mainRegion.Remove(viewExists); } }