WPF, CslaDataProvider, DeferRefresh and Child Lists

WPF, CslaDataProvider, DeferRefresh and Child Lists

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

dagware posted on Saturday, May 22, 2010

I'm using CSLA 3.8.3 in a VS 2008 WPF app. Actually, it's a WinForms app that is hosting a WPF UserControl, but I doubt (or at least hope) that this makes a difference for my question.

This particular UserControl has the outside container's DataContext set to a CslaDataProvider that points to a top-level single parent, with children and grandchildren and great-grandchildren (...).

Here's my issue: When I add a new child using AddNew(), the VS outpout window shows a bunch of binding errors indicating that properties don't exist. It doesn' appear to affect anything, because once the process is finished, the new item shows up and everything's fine. But I don't like seeing the errors, and I'm worried that they are affecting the speed of adding a new item, which takes a few seconds longer than I would have thought it should.

I was hoping that if I wrapped the call to AddNew() with a "using _dp.DeferRefresh", it would eliminate the binding error messages, but it doesn't. So I'm thinking that perhaps the DeferRefresh needs to be called for the child list, which doesn't have its own CslaDataProvider.

So here's my questions:

  1. Should I care about the binding errors? Are they affecting speed at all? Just watching the speed (or lack thereof) at which they're displayed makes me think so - as though handing each binding error takes long enough to add up.
  2. Is there a way to solve this? Can/should I put a CslaDataProvider on the child list (and grandchild list, etc.)? And if so, how do I define it and bind it?
  3. If I can specify a CslaDataProvider for the children, should I make this a regular practice in the future? In other words, is this the "normal' way people handle (or should handle) child lists in WPF?

Thanks for any help!


RockfordLhotka replied on Saturday, May 22, 2010

I don't think the data provider model has a bright future in WPF. You might consider using an MVVM approach with ViewModel<T> viewmodel objects instead of data providers.

In that case you might use a viewmodel for each list, or even each item in each list. Anywhere you need to add verbs/commands to your model, you would use a viewmodel.

dagware replied on Saturday, May 22, 2010

Thanks for the reply, I think Stick out tongue. Man, I'm just now moving from WinForms to WPF, and you want me to learn something else new at the same time? What do you think I am, a software developer or something?

Seriously, thanks for the information. I just wish the target would stand still long enough to hit it, you know what I mean? (Of course you do -- these things impact you way more than they do me...)


dagware replied on Saturday, May 22, 2010

OK, I give. Where can I find information on using CSLA's ViewModel<T>? I'm not talking about abstract concepts like MVVM, but the specifics of using CSLA's ViewModel<T>. I searched this site (perhaps not very well, but as well as I could) for information, and didn't find a whole lot. I looked at MVVMexperiment, and while having examples is nice, it doesn't really explain anything. And "ViewModel" is not in the index of your book (again, I could be blind - in fact, my wife swears I am).

So what do I need to know about ViewModel<T>, and how do I use it? I suppose I can just plug away and code, and see what happens (in fact, I will indeed do that), but I like it a lot better when I've got some idea of what I'm doing before I start doing it. Call me silly...

Any suggestions?


Edit: I'd at least like to know why using a ViewModel<T> will help me over a CslaDataProvider. In other words, how are they different?

Copyright (c) Marimer LLC