ObjectStatus usage

ObjectStatus usage

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


JonM posted on Tuesday, December 21, 2010

I'm trying to upgrade from CSLA.net 2.x to the newer 4.0.1.  So far things are good. I'm trying to figure out how to use the ObjectStatus control to bind to the IsValid property on an object.  I'm a bit confused by it.  How do I associate the ObjectStatus to a CSLA object??  The sample XAML I've seen on the forum doesn't make that clear.

RockfordLhotka replied on Tuesday, December 21, 2010

ObjectStatus is deprecated in favor of ViewModel<T> and CslaDataProvider. You should be able to find all the object-level metastate on the "object manager" you are using, so you shouldn't need ObjectStatus.

JonM replied on Tuesday, December 21, 2010

Thanks for the fast reply.  I've never used the ViewModel<T> before.  Looking at the forums there is a lot of confusion on this one.  It seems like a big piece of architecture to deal with just to databind on IsValid.  I'll dig into it.  Thanks.

RockfordLhotka replied on Tuesday, December 21, 2010

Yeah, maybe.

It depends on whether you buy into the MVVM thing or not. I think it is well worth it, but honestly you don't have to go all the way.

One way or another you should have some "manager" object that gets and saves your object, and you should have a way of making that manager object a resource in your XAML so you can bind to it easily.

ViewModel<T> is a very easy way to create one of these manager objects. And if that's all you use it for you probably aren't really doing MVVM, but it will probably still make your life a lot easier :)

JonM replied on Tuesday, December 28, 2010

So I've spent some time today looking at this.  The ViewModel<T> doesn't appear to have any properties for IsValid.  I've been trying to find a way to hook into the framework somewhere so I can raise the INotifyPropertyChanged event when IsValid changes but no luck so far.  Am I missing something?  It seems like IsValid should already do something like this.  I found that I can attached to the BrokenRulesCollection changed but it turns out the IsValid property hasn't been updated at this point.

Copyright (c) Marimer LLC