The multi page view can now deal with multi page view models that change the active page from a different thread (as it should be, in WPF all bound property change notifications are allowed to come from any thread)
git-svn-id: file:///srv/devel/repo-conversion/nuwi@56 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
e16af9dee9
commit
db68a9741e
|
@ -152,7 +152,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
|
||||||
/// <summary>Runs a background process that causes the specified error</summary>
|
/// <summary>Runs a background process that causes the specified error</summary>
|
||||||
/// <param name="error">Error that will be caused in the background process</param>
|
/// <param name="error">Error that will be caused in the background process</param>
|
||||||
public void CauseErrorInBackgroundThread(Exception error) {
|
public void CauseErrorInBackgroundThread(Exception error) {
|
||||||
RunInBackground(() => throw error);
|
RunInBackground(
|
||||||
|
delegate() { throw error; }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -130,7 +130,7 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
Control control = Controls[index];
|
Control control = Controls[index];
|
||||||
|
|
||||||
// Only check container controls
|
// Only check container controls
|
||||||
if((control is ContainerControl) || (control is Panel)) {
|
if((control is ContainerControl) || (control is Panel)) {
|
||||||
if(firstContainer == null) {
|
if(firstContainer == null) {
|
||||||
firstContainer = control;
|
firstContainer = control;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,14 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
if(arguments.AreAffecting(nameof(MultiPageViewModel<object>.ActivePage))) {
|
if(arguments.AreAffecting(nameof(MultiPageViewModel<object>.ActivePage))) {
|
||||||
var viewModelAsMultiPageviewModel = DataContext as IMultiPageViewModel;
|
var viewModelAsMultiPageviewModel = DataContext as IMultiPageViewModel;
|
||||||
if(viewModelAsMultiPageviewModel != null) {
|
if(viewModelAsMultiPageviewModel != null) {
|
||||||
activatePageView(viewModelAsMultiPageviewModel.GetActivePageViewModel());
|
if(InvokeRequired) {
|
||||||
|
Invoke(
|
||||||
|
new Action<object>(activatePageView),
|
||||||
|
viewModelAsMultiPageviewModel.GetActivePageViewModel()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
activatePageView(viewModelAsMultiPageviewModel.GetActivePageViewModel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +217,7 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
var activePageViewAsView = this.activePageView as IView;
|
var activePageViewAsView = this.activePageView as IView;
|
||||||
if(activePageViewAsView == null) {
|
if(activePageViewAsView == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return activePageViewAsView.DataContext;
|
return activePageViewAsView.DataContext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +264,7 @@ namespace Nuclex.Windows.Forms.Views {
|
||||||
disableActivePageView();
|
disableActivePageView();
|
||||||
} else {
|
} else {
|
||||||
Control pageViewContainer = getPageViewContainer();
|
Control pageViewContainer = getPageViewContainer();
|
||||||
using(new RedrawLockScope(pageViewContainer)) {
|
using(new RedrawLockScope(pageViewContainer)) {
|
||||||
disableActivePageView();
|
disableActivePageView();
|
||||||
|
|
||||||
this.activePageView = getOrCreatePageView(pageViewModel);
|
this.activePageView = getOrCreatePageView(pageViewModel);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user