PageRenderTime 47ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/V4/Quickstarts/MVVM/MVVM/ViewModels/OpenQuestionViewModel.cs

#
C# | 46 lines | 27 code | 3 blank | 16 comment | 2 complexity | 68ddaa56e3b95f576dfabffba1dfdb02 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.ComponentModel;
  18. using MVVM.Model;
  19. namespace MVVM.ViewModels
  20. {
  21. public class OpenQuestionViewModel : QuestionViewModel<OpenQuestion>
  22. {
  23. public OpenQuestionViewModel(OpenQuestion question)
  24. : base(question)
  25. {
  26. }
  27. public int AvailableLength
  28. {
  29. get
  30. {
  31. return this.Question.MaxLength - (this.Question.Response ?? string.Empty).Length;
  32. }
  33. }
  34. protected override void OnQuestionPropertyChanged(object sender, PropertyChangedEventArgs e)
  35. {
  36. if (e.PropertyName == "Response")
  37. {
  38. this.RaisePropertyChanged(() => this.AvailableLength);
  39. this.OnResponseChanged();
  40. }
  41. }
  42. }
  43. }