c# - WPF data binding cancel operation -


I have some controls that are bound to individual domain objects. I have some basic updates for the database through those items Operations must be implemented. I am using MVVM command binding to update database. The problem is the cancel button, which basically reloads the original value. I temporarily reloaded objects from the database, but it has to be changed soon.

Due to not allowing easy cloning of objects, the object was not copied and manually object synchronized.

UpdateSource seems to be the best solution manually for Binding and Calling UpdateSourceTrigger, but could not find any way to implement it because I have a visual model (or command) There is no direct access to see the control from

Any thoughts?

I remember when UpdateSourceTrigger is struggling with Explicit. Later I had the same problem (I needed access to visual controls). This was when I came to know that the model is nothing to maintain the status of WPF View, but there is also a way to present the data and in this situation your data is some of the hydrated groups from the database.

I will do something like this:

[View WPF Model - & gt; Unit visual model] - & gt; Unit VM Unit Translation - & gt; Database

Note about it in your ViewModel:

Public supervision & lt; MyEntity & gt; MyEntities

Do this:

Public Supervision Collection & lt; MyEntityViewModel & gt; MyEntities

Where MyEntityViewModel My Entity

has a VM, explain me a bit more : The WPF View Model VM should present data wrapped. This presentation is for purposes, if you have a fairly complex demographic object graph, but you only need to display name, date of birth and what will happen? Navigating the object graph is much easier to create a visual model object to wrap up those three qualities. This is the reason that the tools exist.

What is the benefit of all this?

  • You do not need to duplicate the object graph to test yourself

  • You see ViewModel. If you cancel, you do not have to do this again or again. You are not touching enties despite the assumptions being successful.

    Of course, this is probably not fit in all scenarios, and maybe you can think of something in between.

    hh

Comments