Data refresh in WPF

Data refresh in WPF

Old forum URL: forums.lhotka.net/forums/t/3656.aspx


Paul Czywczynski posted on Friday, October 05, 2007

Hey Rocky, I've been following your blog post regarding this topic. Your last comment was interesting and I was wondering if you have anything further info. We've noticed the exact same issue with things being one step behind. Not sure if you have talked to the WPF team yet but I am interested in what they have to say.

Thanks...  -Paul

RockfordLhotka replied on Sunday, October 07, 2007

Hi Paul,

I did finally finally figure out the issue. I was using the CslaDataProvider's ability to manage the object lifetime by binding a button to the provider using commanding. AND I was using the Click event of the button to close the form (thus triggering the refresh of the underlying view).

It turns out that the Click event fires BEFORE the command is sent to the provider. So the form closes, the view refreshes and THEN the command hits the provider.

I can't see any way to force a button to do the Click after the command.

So what I did was make the edit form (which is an overlay in our case) close itself on the DataChanged event from the provider. The Click event doesn't close the overlay anymore. Instead it sets a flag giving the DataChanged event handler permission to close the form.

That way, when the overlay closes, the underlying view can refresh itself, with the new data.

The Equals() issue still remains though. That's not changed from how it has been since WPF showed up, and I think their approach really sucks. But it is what it is I guess.

CSLAer replied on Monday, October 08, 2007

Hi Rocky,

Is there any changes to the code which is released at the end of last month if this is the case?

Thanks

RockfordLhotka replied on Monday, October 08, 2007

No, ProjectTracker is unaffected by this issue.

In the project I'm currently building there's a detailed view of data as the main display. You can click to edit parts of that detailed information, and when that happens there's an overlay (user control) that comes in on top of the view (via a cool animation - working with a professional designer is fun!), and the original view fades out a bit.

The user edits the data in the overlay and clicks Save. That button is linked to the CslaDataProvider via a command - just like in PTWpf. But I was also handling the Click event to close the form and to tell the underlying view to refresh itself. That didn't work due to the timing issue.

PTWpf has no underlying view, so this issue doesn't exist.

But in my current project, the solution was to have the Click handler just set a flag to indicate that the overlay form is closing. Then in the CslaDataProvider control's DataChanged event handler (which is raised when the data save is complete), if that flag is set, the underlying view is told to refresh its data.

My current project will (I think) be ultimately put online as a demo, but this is for Magenic, not me, so I don't know for sure when or if it will go online.

Copyright (c) Marimer LLC