Using LLBLGen 3.5, Adapter General2010, SQL2008R2, .NET 4.0, VS2010, WPF
Hello,
I'm using LLBLGen generated code all the way up to my viewmodel-layer so I can use all the built-in plumbing of NotifyPropertyChanged (works wonderfully)
Now one of the requiremens is to show an asterisk in the tab-labels when an entity "IsDirty" (or one of it's subcollections ContainsDirtyContents). I would like to do this via a Binding in WPF, Something like :
<TextBlock Text="*" Visibility="{Binding Entity.IsDirty,Converter={StaticResource booleanToVisibility}}"/>
I was surprised to find out that the IsDirty property on an entity is not out-of-the-box notified of changes. But of course this could quickly be solved by adding the following piece in CommonEntityBase:
protected override void OnInitialized()
{
this.EntityContentsChanged += (sender, args) => OnPropertyChanged("IsDirty");
base.OnInitialized();
}
But this doesn't solve the problem of the notification of "dirtyness" when the subcollections contain dirty items.
I was thinking of some kind of property like this (on CommonEntityBase) :
public bool HasDirtyContent
{
get
{
bool result = this.IsDirty;
foreach (var subcoll in this.GetMemberEntityCollections())
{
if (subcoll.ContainsDirtyContents)
{
result = true;
}
}
return result;
}
}
But how can I get notification of this property ? (without generating memory leaks
Or is there a better way to achieve this ?
Thnx in advance
Sven.