IsDirty property stays False

IsDirty property stays False

Old forum URL: forums.lhotka.net/forums/t/3929.aspx


Jelle posted on Thursday, November 22, 2007

Hi,

In my project I use the BusinessListBase which contains a list of the Type Question(which is inherited from the BusinessBas class)

But when i'm editing these Question Objects which are listed in my BusinessListBase Object, the IsDirty property is never changed to True.

Which method manages the IsDirty property, and when is it called? > Or should i call it myself after changing?

greetz,

Jelle

richardb replied on Thursday, November 22, 2007

On your child objects each property should Call PropertyHasChanged.  This, I believe sets the dirty flag, and also fires off any rule validation.

public string Description
{
   get
   {
      CanReadProperty(true);
      return _description;
   }
   set
   {
      CanWriteProperty(true);
      if (value == null) value = string.Empty;
      if (_description != value)
      {
         _description = value;
         PropertyHasChanged();
      }
   }
}

JoeFallon1 replied on Sunday, November 25, 2007

I recommend you use the overload of the method that takes the tring name of the Property.

 PropertyHasChanged("Description");

This avoids many issues and provides clarity. Also, it is very easy to do when you use a code generator.

If you don't use it then you have to add the no-inlining attribute. Plus there is a small perf hit using the stack trace to figure out the String Property name. Plus there are now some issues with it in WPF, I think. So overall it is easier and better to just provide the property name.

Joe

Copyright (c) Marimer LLC