Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DispatcherViewModel.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 
4 using SiliconStudio.Core;
5 using SiliconStudio.Presentation.Services;
6 
7 namespace SiliconStudio.Presentation.ViewModel
8 {
9  /// <summary>
10  /// This abstract class is an implementation of <see cref="ViewModelBase"/> that uses a dispatcher to invoke
11  /// <see cref="OnPropertyChanging"/> and <see cref="OnPropertyChanged"/> handlers.
12  /// </summary>
13  public abstract class DispatcherViewModel : ViewModelBase
14  {
15  /// <summary>
16  /// Initializes a new instance of the <see cref="DispatcherViewModel"/> class.
17  /// </summary>
18  /// <param name="serviceProvider">A service provider that can provide a <see cref="IDispatcherService"/> to use for this view model.</param>
20  : base(serviceProvider)
21  {
22  Dispatcher = serviceProvider.Get<IDispatcherService>();
23  }
24 
25  /// <summary>
26  /// Gets a dispatcher that is capable of executing code in the UI thread.
27  /// </summary>
28  [DataMemberIgnore]
29  public IDispatcherService Dispatcher { get; private set; }
30 
31  /// <inheritdoc/>
32  protected override void OnPropertyChanging(params string[] propertyNames)
33  {
34  Dispatcher.Invoke(() => base.OnPropertyChanging(propertyNames));
35  }
36 
37  /// <inheritdoc/>
38  protected override void OnPropertyChanged(params string[] propertyNames)
39  {
40  Dispatcher.Invoke(() => base.OnPropertyChanged(propertyNames));
41  }
42  }
43 }
This abstract class represents a basic view model, implementing INotifyPropertyChanging and INotifyPr...
override void OnPropertyChanged(params string[] propertyNames)
This method will raise the PropertyChanged for each of the property name passed as argument...
DispatcherViewModel(IViewModelServiceProvider serviceProvider)
Initializes a new instance of the DispatcherViewModel class.
This abstract class is an implementation of ViewModelBase that uses a dispatcher to invoke OnProperty...
override void OnPropertyChanging(params string[] propertyNames)
This method will raise the PropertyChanging for each of the property name passed as argument...