Hi,
I was looking for event IsDirtyChanged which would indicate when IsDirty has changed.
What I found is OnIsDirtyChanged method in BindableBase class, but in the comment there is stated "This method is for backward compatibility with CSLA .NET 1.x.". And as I can see this method is never called.
I would like to implement UI indication when an business object becomes "dirty" and when it becomes "clean" by showing an asterisk in the title bar of the window.
BusinessBase class provides PropertyChanged and ChildChanged events. This is what I can use. So to encapsulate this for common use I need to create own event IsDirtyChanged which would be triggered when in PropertyChanged and ChildChanged is IsDirty is detected as changed with respect to previous remembered value.
But as you can see this is something like an old OnIsDirtyChanged() method, which is unsupported on the latest version of Csla. Is there something wrong whith this approach. Why is this method/event unsupported? Is it safe to implement this behavior?
Thank You
Yours sincerely
Miroslav Galajda
Which type of UI do you use?
The typical recommendation for WPF / SL is to use the ViewModel base class that will give you meta properties as bindable properties.
Having meta state properties raise OnPropertyChanged is not recommended for Windows Forms. Adding OnPropertyChanged for all the metaproperties in Windows Forms could seriously degrade performance / user experience.
We have an issue in bugtracker concerning BusinessBase to raise OnPropertyChanged for IsXYZ properties when not in Windows Forms but work is not in progress yet.
So the proposed solution for all other platforms than .NET would be to raise PropertyChanged events on IsValid and others when user interface is not Windows Forms. You could create this yourself by overriding
protected override void PropertyHasChanged(IPropertyInfo property) { base.PropertyHasChanged(property); OnPropertyChanged("IsDirty"); } protected override void OnChildChanged(ChildChangedEventArgs e) { base.OnChildChanged(e); OnPropertyChanged("IsDirty"); }
Unfortunately I'm developing for Windows Forms.
So what do you propose for Windows Forms?
Thank You
I'd prefer to hook into the PropertyChanged and ChildChanged events on the "root" object in the Form and update the title based on <root>.IsDirty.
Remember to unhook before Save and rehook to the new object after Save.
OK, thank you.
Copyright (c) Marimer LLC