IsDirty OnPropertyChanged?

IsDirty OnPropertyChanged?

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


gstempeck posted on Thursday, April 22, 2010

Greetings,

Just a suggestion for inclusion to CSLA at some point.  We have styles that change based on IsNew, IsSaveable, etc - but adding a similar style for IsDirty doesn't work out well because it's missing an OnPropertyChanged.

This may have already been suggested, but if not - I think this would be helpful for WPF development purposes.

For example,

protected void MarkDirty(bool suppressEvent)

{

    // Add code to call OnPropertyChanged for IsDirty specifically

    this._isDirty = true; this.OnPropertyChanged("IsDirty");

    if (!suppressEvent)

    {

        this.OnUnknownPropertyChanged();

    }

}

Hope all is well,

GS

RockfordLhotka replied on Thursday, April 22, 2010

Thank you for the feedback.

This has been discussed many times. The problem is that this change would conflict with Windows Forms behaviors, and a lot of people still use Windows Forms. Eventually I'm sure I'll make this change, but transition takes time.

In the meantime there are good answers for WPF users - most notably the ViewModelBase and CslaDataProvider types, along with the ObjectStatus component. All three of these are WPF components that elevate important metastate properties to a bindable level, including raising appropriate PropertyChanged events.

Copyright (c) Marimer LLC