PageRenderTime 60ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 0ms

/Visual Studio 2008/CSWPFAnimationWhenDataChanged/DataModel.cs

#
C# | 96 lines | 58 code | 3 blank | 35 comment | 2 complexity | c8edcd67290ba3456743b0188068379e MD5 | raw file
  1. /************************************* Module Header **************************************\
  2. * Module Name: DataModel.cs
  3. * Project: CSWPFAnimationWhenDataChanged
  4. * Copyright (c) Microsoft Corporation.
  5. *
  6. * This example demonstrates how to trigger animation when the value of the datagrid cell is
  7. * changed.
  8. *
  9. *
  10. * This source is subject to the Microsoft Public License.
  11. * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
  12. * All other rights reserved.
  13. *
  14. * History:
  15. * * 11/30/2009 3:00 PM Bruce Zhou Created
  16. *
  17. \******************************************************************************************/
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.ComponentModel;
  23. using System.Collections.ObjectModel;
  24. namespace CSWPFAnimationWhenDataChanged
  25. {
  26. //datamodel used by the application, fetched from msdn
  27. public class NameList : ObservableCollection<PersonName>
  28. {
  29. public NameList()
  30. : base()
  31. {
  32. Add(new PersonName("Willa", "Cather"));
  33. Add(new PersonName("Isak", "Dinesen"));
  34. Add(new PersonName("Victor", "Hugo"));
  35. Add(new PersonName("Jules", "Verne"));
  36. }
  37. }
  38. public class PersonName : INotifyPropertyChanged
  39. {
  40. private string firstName;
  41. private string lastName;
  42. /// <summary>
  43. /// Initializes a new instance of the <see cref="PersonName"/> class.
  44. /// </summary>
  45. /// <param name="first">firstName.</param>
  46. /// <param name="last">lastName.</param>
  47. public PersonName(string first, string last)
  48. {
  49. this.firstName = first;
  50. this.lastName = last;
  51. }
  52. /// <summary>
  53. /// Gets or sets the firstName.
  54. /// </summary>
  55. /// <value>The first name.</value>
  56. public string FirstName
  57. {
  58. get { return firstName; }
  59. set
  60. {
  61. firstName = value;
  62. OnPropertyChanged("FirstName");
  63. }
  64. }
  65. /// <summary>
  66. /// Gets or sets the lastName.
  67. /// </summary>
  68. /// <value>The last name.</value>
  69. public string LastName
  70. {
  71. get { return lastName; }
  72. set
  73. {
  74. lastName = value;
  75. OnPropertyChanged("LastName");
  76. }
  77. }
  78. #region INotifyPropertyChanged Members
  79. public event PropertyChangedEventHandler PropertyChanged;
  80. #endregion
  81. /// <summary>
  82. /// Called when [property changed].
  83. /// </summary>
  84. /// <param name="propertyName">Name of the property.</param>
  85. void OnPropertyChanged(string propertyName)
  86. {
  87. if (PropertyChanged != null)
  88. {
  89. PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  90. }
  91. }
  92. }
  93. }