when the Silverlight dataform’s property autogeneratedfields is set to true everything works fine (the button behavior is correct, meaning as soon as I start typing it gets enabled. So, now i have a scenario where i had to customize the look of the dataform and set autogeneratefields to false ( i am manually using datafields in xaml) , when i type in something in a textbox, the commit button is not enabled, it only gets enabled when i put the mouse in the next textbox. Any help appreciated. Thanks.
when the Silverlight dataform’s property autogeneratedfields is set to true everything works fine (the
Share
Try making your object an
IEditableObject(System.ComponentModel).What’s cool about the
DataFormis that it tries to communicate with the object with the current state of what’s going on. IfAutoGenerateFieldsis being used, then there is something that is between the templating engine of the dataform and the object it is trying to use, thus making completing the loop for you.If there isn’t an interface (because you provided the template, yourself) to an
IEditableObjectavailable, theDataFormdoesn’t know it is actually editing an object until a Binding is updated. In Silverlight, Bindings are updated only AFTER the aTextBoxhas lost focus.The point of an IEditableObject is to tell objects that this guy knows how to Cancel and Save appropriately. This is especially important when the MSDN documentation tells us we need to be able to rollback the object to its original state. So when you begin your edit, you can keep a copy of it around. Then, when cancel is clicked, you will be able to rollback your changes by copying the data back. I’d check out the MSDN article, they do a good job explaining it.
If you make your objects an
IEditableObject, then this behavior may return to the way you want. If not, then I do not understand the problem correctly and would love to see the code for a small sample.Also, feel free to check out the source code for the
DataFormon CodePlex: http://silverlight.codeplex.com/SourceControl/changeset/view/71382I’ve had to browse the code many times to figure something out.
Best of luck!