Added properties to access the active page view and page view model
git-svn-id: file:///srv/devel/repo-conversion/nuwi@55 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
b69488f9a6
commit
e16af9dee9
|
@ -66,7 +66,7 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
/// <param name="cachePageViews">Whether page views should be kept alive and reused</param>
|
/// <param name="cachePageViews">Whether page views should be kept alive and reused</param>
|
||||||
public MultiPageViewForm(IWindowManager windowManager, bool cachePageViews = false) {
|
public MultiPageViewForm(IWindowManager windowManager, bool cachePageViews = false) {
|
||||||
this.windowManager = windowManager;
|
this.windowManager = windowManager;
|
||||||
this.createViewMethod = typeof(IWindowManager).GetMethod("CreateView");
|
this.createViewMethod = typeof(IWindowManager).GetMethod(nameof(IWindowManager.CreateView));
|
||||||
|
|
||||||
if(cachePageViews) {
|
if(cachePageViews) {
|
||||||
this.cachedViews = new Dictionary<Type, Control>();
|
this.cachedViews = new Dictionary<Type, Control>();
|
||||||
|
@ -191,8 +191,7 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
) {
|
) {
|
||||||
base.OnViewModelPropertyChanged(sender, arguments);
|
base.OnViewModelPropertyChanged(sender, arguments);
|
||||||
|
|
||||||
MultiPageViewModel<bool> anyMultiPageViewModel;
|
if(arguments.AreAffecting(nameof(MultiPageViewModel<object>.ActivePage))) {
|
||||||
if(arguments.AreAffecting(nameof(anyMultiPageViewModel.ActivePage))) {
|
|
||||||
var viewModelAsMultiPageviewModel = DataContext as IMultiPageViewModel;
|
var viewModelAsMultiPageviewModel = DataContext as IMultiPageViewModel;
|
||||||
if(viewModelAsMultiPageviewModel != null) {
|
if(viewModelAsMultiPageviewModel != null) {
|
||||||
activatePageView(viewModelAsMultiPageviewModel.GetActivePageViewModel());
|
activatePageView(viewModelAsMultiPageviewModel.GetActivePageViewModel());
|
||||||
|
@ -200,6 +199,23 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Currently active page view control</summary>
|
||||||
|
protected Control ActivePageView {
|
||||||
|
get { return this.activePageView; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The view model running the currently active page</summary>
|
||||||
|
protected object ActivePageViewModel {
|
||||||
|
get {
|
||||||
|
var activePageViewAsView = this.activePageView as IView;
|
||||||
|
if(activePageViewAsView == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return activePageViewAsView.DataContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Activates the page view for the specified page view model</summary>
|
/// <summary>Activates the page view for the specified page view model</summary>
|
||||||
/// <param name="pageViewModel">
|
/// <param name="pageViewModel">
|
||||||
/// Page view model for which the page view will be activated
|
/// Page view model for which the page view will be activated
|
||||||
|
|
Loading…
Reference in New Issue
Block a user