/Templates/ProjectTemplates/WPF/MvvmLight.WPF/MainViewModel.cs
C# | 75 lines | 40 code | 10 blank | 25 comment | 4 complexity | 6d577a6a42c68359423f6c18a6430017 MD5 | raw file
✨ Summary
- using GalaSoft.MvvmLight;
- using $safeprojectname$.Model;
-
- namespace $safeprojectname$.ViewModel
- {
- /// <summary>
- /// This class contains properties that the main View can data bind to.
- /// <para>
- /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
- /// </para>
- /// <para>
- /// See http://www.galasoft.ch/mvvm/getstarted
- /// </para>
- /// </summary>
- public class MainViewModel : ViewModelBase
- {
- private readonly IDataService _dataService;
-
- /// <summary>
- /// The <see cref="WelcomeTitle" /> property's name.
- /// </summary>
- public const string WelcomeTitlePropertyName = "WelcomeTitle";
-
- private string _welcomeTitle = string.Empty;
-
- /// <summary>
- /// Gets the WelcomeTitle property.
- /// Changes to that property's value raise the PropertyChanged event.
- /// </summary>
- public string WelcomeTitle
- {
- get
- {
- return _welcomeTitle;
- }
-
- set
- {
- if (_welcomeTitle == value)
- {
- return;
- }
-
- _welcomeTitle = value;
- RaisePropertyChanged(WelcomeTitlePropertyName);
- }
- }
-
- /// <summary>
- /// Initializes a new instance of the MainViewModel class.
- /// </summary>
- public MainViewModel(IDataService dataService)
- {
- _dataService = dataService;
- _dataService.GetData(
- (item, error) =>
- {
- if (error != null)
- {
- // Report error here
- return;
- }
-
- WelcomeTitle = item.Title;
- });
- }
-
- ////public override void Cleanup()
- ////{
- //// // Clean up if needed
-
- //// base.Cleanup();
- ////}
- }
- }