An MVVM way to know when a database update is complete in order to navigate to another page.
-
So, I have everything completed with no code in the code behind. I have everything separated. How should my view model notify the view that the database update has worked? Any thoughts or examples on how to do this?
I didn't get any requirements for the signature
-
So, I have everything completed with no code in the code behind. I have everything separated. How should my view model notify the view that the database update has worked? Any thoughts or examples on how to do this?
I didn't get any requirements for the signature
You could simply add a dirty flag and bind to this.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
So, I have everything completed with no code in the code behind. I have everything separated. How should my view model notify the view that the database update has worked? Any thoughts or examples on how to do this?
I didn't get any requirements for the signature
Your VM needs to expose some property that indicates success or failure. You might need a converter because there are three or four states you're talking about: 1. Don't have a pending update 2. Have a pending update 3. Update failed 4. Update passed (2. is only appropriate for asynchronous updates) So your VM has a property that starts off with a value 1. When the 'save' command is triggered, it is set to 2. When the results of the Save are returned t is set to 3 or 4 respectively. You could 'merge' this with any process you are using to enable/disable the Save button - so add another state ... 0. Nothing To Save
___________________________________________ .\\axxx (That's an 'M')
-
So, I have everything completed with no code in the code behind. I have everything separated. How should my view model notify the view that the database update has worked? Any thoughts or examples on how to do this?
I didn't get any requirements for the signature
Bind the status to a textblock and create a property for it in your view model (assuming everything is bound to the view model). Once your async web service comese back from the server, fire an action to get to the view model and then let INotifyPropertyChanged take over to update the status.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick
-
Bind the status to a textblock and create a property for it in your view model (assuming everything is bound to the view model). Once your async web service comese back from the server, fire an action to get to the view model and then let INotifyPropertyChanged take over to update the status.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick
This is what I did. I guess the user will have to click a link to navigate, or I can put that in the code behind. Thanks for the reply.
I didn't get any requirements for the signature
-
This is what I did. I guess the user will have to click a link to navigate, or I can put that in the code behind. Thanks for the reply.
I didn't get any requirements for the signature
Strange. You should not need to - are the datacontext's correct?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick
-
So, I have everything completed with no code in the code behind. I have everything separated. How should my view model notify the view that the database update has worked? Any thoughts or examples on how to do this?
I didn't get any requirements for the signature
We use the MVVMlight framework from Galasoft, it has a messaging construct. In the completed method we send the name of the method via a
Completed
message pump, the relevant view or viewmodel subscribes to theCompleted
message, checks the message content and takes action as appropriate. We use a VERY simplified structure, I know it can get a lot more complex but this meets our current needs. However I rarely (never) use it to navigate as the datacontext generally meets our needs (data refreshes after the call and updates the UI via onpropertychanged)Never underestimate the power of human stupidity RAH