/V4/MVVM RI/MVVM.Client/ViewModels/QuestionViewModel.cs

# · C# · 59 lines · 33 code · 7 blank · 19 comment · 2 complexity · abd3c2aee14cd41cc122db8ce771d626 MD5 · raw file

  1. //===================================================================================
  2. // Microsoft patterns & practices
  3. // Composite Application Guidance for Windows Presentation Foundation and Silverlight
  4. //===================================================================================
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
  7. // OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
  8. // LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  9. // FITNESS FOR A PARTICULAR PURPOSE.
  10. //===================================================================================
  11. // The example companies, organizations, products, domain names,
  12. // e-mail addresses, logos, people, places, and events depicted
  13. // herein are fictitious. No association with any real company,
  14. // organization, product, domain name, email address, logo, person,
  15. // places, or events is intended or should be inferred.
  16. //===================================================================================
  17. using System;
  18. using Microsoft.Practices.Prism.ViewModel;
  19. namespace MVVM.Client.ViewModels
  20. {
  21. /// <summary>
  22. /// View model for a question.
  23. /// </summary>
  24. public abstract class QuestionViewModel : NotificationObject
  25. {
  26. private bool hasChanges;
  27. protected QuestionViewModel()
  28. {
  29. }
  30. public event EventHandler<EventArgs> ResponseChanged;
  31. public bool HasChanges
  32. {
  33. get
  34. {
  35. return this.hasChanges;
  36. }
  37. }
  38. public abstract bool ResponseComplete { get; }
  39. protected void OnResponseChanged()
  40. {
  41. var handler = this.ResponseChanged;
  42. if (handler != null)
  43. {
  44. handler(this, EventArgs.Empty);
  45. }
  46. }
  47. protected void SetHasChanges()
  48. {
  49. this.hasChanges = true;
  50. }
  51. }
  52. }