New Posts New Posts RSS Feed: propertychanged event for mvvm
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

propertychanged event for mvvm

 Post Reply Post Reply
Author
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Topic: propertychanged event for mvvm
    Posted: 23-Jul-2010 at 3:08pm

The PropertyChanged events do not fire when the entity is in a detached state (this is the state a new entity is in before adding it to an EntityManager).  Once you call entityManager.AddEntity(myEmployee) it will start firing.

Back to Top
hueha View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 38
Post Options Post Options   Quote hueha Quote  Post ReplyReply Direct Link To This Post Posted: 23-Jul-2010 at 1:59pm
Ok it seems it is firing for edits when I load the object from the database but not when it's fresh new object.  Is this a bug?
Back to Top
hueha View Drop Down
Newbie
Newbie


Joined: 23-Jul-2010
Posts: 38
Post Options Post Options   Quote hueha Quote  Post ReplyReply Direct Link To This Post Posted: 23-Jul-2010 at 1:47pm
I'm trying to implement mvvm in my class.  I want to catch the propertychanged event in the entity class and bubble it up.

Using your simplecombobox project as an example I added the following class to the simplecombodemo project.  Am I catching the propertychanged event correctly?  Because I am not getting the propertychanged event when I do Class1.Employee.Address="abc"


using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using IdeaBlade.EntityModel;

namespace SimpleComboDemo
{
    public class Class1
    {
        private Employee myEmployee;
        public string propname;
        public Employee Employee
        {
            get { return myEmployee; }
        }

        public Class1()
        {
            myEmployee = new Employee();
            myEmployee.PropertyChanged += new PropertyChangedEventHandler(MyCust_PropertyChanged);
        }
        private void MyCust_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var propchange = e.PropertyName;
        }
    }
}




Edited by hueha - 23-Jul-2010 at 1:50pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down