I've got a RIA silverlight 4 app with a complex data type as a model. As a familiar example let's call it aspnet_User which has a member object called aspnet_Membership; aspnet_User has a member called "UserName" and aspnet_Membership has a member called "Email". Now using the aspnet_User as a datacontext I want to bind to any changes in aspnet_User or an attached aspnet_Membership - i.e. I want to show if an aspnet_User is 'dirty'. The dirty flag should show if I change either aspnet_User.UserName or aspnet_Membership.Email. Now previously I have implemented a Converter and bound to the EntityState on an object, and this is fine for showing whether simple properties are dirty but EntityState is not altered when aspects of aspnet_Membership member are edited.
I have tried to implement a property called BubbledEntityState which reflects a modified EntityState on either aspnet_User or aspnet_membership. It is defined in a partial class in the Silverlight project. This needs to react to EntityState PropertyChanged events on aspnet_User or it's member aspnet_Membership. So I've tried to handle these events in the partial OnCreated method. Strangely however this isn't getting called at all. Here is the method: public partial class aspnet_User {
partial void OnCreated()
{
this.aspnet_Membership.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(aspnet_Membership_PropertyChanged);
this.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(aspnet_User_PropertyChanged);
}
... }
I'm presuming aspnet_User objects are constructed on the server and are not 'reconstructed' when they are reconstituted on the client after RIA has done it's WCF call. This strikes me as peculiar. Am I doing something cranky? Anyone got a better way of dealing with this?