When the TextBox(binding MaterialNo and apply ToUpperCase rule) changed. the ViewModelBase's CanSave is still false.
If remove the below code in BussinessCore of CustomFiled, will run well.
public override bool IsSelfDirty
{
get
{
if (IsDeleted) return true;
var isSelfDirty = false;
foreach (var registeredProperty in this.FieldManager.GetRegisteredProperties())
{
if (registeredProperty.RelationshipType.HasFlag(RelationshipTypes.Child))
{
// skip lazy fields (is by definition child object)
if (!registeredProperty.RelationshipType.HasFlag(RelationshipTypes.LazyLoad))
{
var fieldData = FieldManager.GetFieldData(registeredProperty);
// fielddata object implements ITrackStatus it is a child object and must be excluded
if (!(fieldData is Csla.Core.ITrackStatus))
{
if (this.FieldManager.IsFieldDirty(registeredProperty))
{
isSelfDirty = true;
break;
}
}
}
}
else
{
if (this.FieldManager.IsFieldDirty(registeredProperty))
{
isSelfDirty = true;
break;
}
}
}
return isSelfDirty;
}
}
1. That is the expected behvior when datasource updatemode is OnPropertyChanged. If you want to change the characters to uppercase as the user types then this must be handled in the UI code.
2. CustomFieldData ha its own implementation of IsDirty handling. You'll have to debug this code.
I found the reason.
the ToUpperCase will invoke the MarkClean again.
public override void MarkClean()
{
base.MarkClean();
this.SetOriginalValue(this.Value);
}
this cause the OriginalValue be set again with the new value( convert by ToUpperCase).
but i don't find solution to avoid it.
Please help me. thank you.
Hi,
In this case look for overrides of LoadProperty in your business objects (BusinessCore?).
CSLA rule engine will only call LoadProperty to update the value.
Copyright (c) Marimer LLC