PageRenderTime 118ms CodeModel.GetById 111ms app.highlight 4ms 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
19using System;
20using System.Collections.Generic;
21using System.Linq;
22using System.Text;
23using System.ComponentModel;
24using System.Collections.ObjectModel;
25namespace CSWPFAnimationWhenDataChanged
26{
27    //datamodel used by the application, fetched from msdn
28    public class NameList : ObservableCollection<PersonName>
29    {
30        public NameList()
31            : base()
32        {
33            Add(new PersonName("Willa", "Cather"));
34            Add(new PersonName("Isak", "Dinesen"));
35            Add(new PersonName("Victor", "Hugo"));
36            Add(new PersonName("Jules", "Verne"));
37        }
38    }
39    public class PersonName : INotifyPropertyChanged
40    {
41        private string firstName;
42        private string lastName;
43        /// <summary>
44        /// Initializes a new instance of the <see cref="PersonName"/> class.
45        /// </summary>
46        /// <param name="first">firstName.</param>
47        /// <param name="last">lastName.</param>
48        public PersonName(string first, string last)
49        {
50            this.firstName = first;
51            this.lastName = last;
52        }
53        /// <summary>
54        /// Gets or sets the firstName.
55        /// </summary>
56        /// <value>The first name.</value>
57        public string FirstName
58        {
59            get { return firstName; }
60            set
61            {
62                firstName = value;
63                OnPropertyChanged("FirstName");
64            }
65        }
66
67        /// <summary>
68        /// Gets or sets the lastName.
69        /// </summary>
70        /// <value>The last name.</value>
71        public string LastName
72        {
73            get { return lastName; }
74            set
75            {
76                lastName = value;
77                OnPropertyChanged("LastName");
78            }
79        }
80
81        #region INotifyPropertyChanged Members
82        public event PropertyChangedEventHandler PropertyChanged;
83        #endregion
84        /// <summary>
85        /// Called when [property changed].
86        /// </summary>
87        /// <param name="propertyName">Name of the property.</param>
88        void OnPropertyChanged(string propertyName)
89        {
90            if (PropertyChanged != null)
91            {
92                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
93            }
94        }
95    }
96}