Click here to Skip to main content
15,878,543 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

I have a ListBox with the name and address of my customers displayed in a data template. When I select an item it opens an edit form with other information. I am using two-way binding and have set the UpdateSourceTrigger=PropertyChanged.
I have a save and cancel button on the edit form. The save event persist the changes to the database.(linq to SQL)

How can I get the cancel event to undo the changes I have made in the edit form if I do not want to persist the changes? As it is now if I select cancel and display my listbox form. The changes are displayed.
My second dilemma is. I have validation on the edit form. However the changes still update the source even if it violates the validation rule. I tried setting the UpdateSourceTrigger=Explicit. When this was done. The errors on the UI were not working, E.g., I could clear the name field and no notification will show. This was not the case when I set UpdateSourceTrigger=PropertyChanged.
I welcome you help
Thanks
Posted
Updated 9-Jul-10 5:16am
v2

1 solution

Change the trigger to bind to the state of an internal bool property that indicates whether or not the user clicked okay or not...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900