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:
Markus Ewald 2019-02-16 20:06:34 +00:00
parent e16af9dee9
commit db68a9741e
2 changed files with 14 additions and 5 deletions

View File

@ -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>

View File

@ -194,10 +194,17 @@ 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) {
if(InvokeRequired) {
Invoke(
new Action<object>(activatePageView),
viewModelAsMultiPageviewModel.GetActivePageViewModel()
);
} else {
activatePageView(viewModelAsMultiPageviewModel.GetActivePageViewModel()); activatePageView(viewModelAsMultiPageviewModel.GetActivePageViewModel());
} }
} }
} }
}
/// <summary>Currently active page view control</summary> /// <summary>Currently active page view control</summary>
protected Control ActivePageView { protected Control ActivePageView {