BusinessBase.IsSave can not reflact enable property of Button in Silverlight

BusinessBase.IsSave can not reflact enable property of Button in Silverlight

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


patelravij@gmail.com posted on Tuesday, April 17, 2012

I have ViewModel<T> business class and I have added Property of another businessclass to Validate search parameter. I have bound IsEnabled property of search button with businessclass object.IsValid Property.

But it does not get reflated when all required fields are selected.

Any Idea how to reflect UI with businessobject IsValid property

Does IsValid  is dependency property?

RockfordLhotka replied on Tuesday, April 17, 2012

That is correct. None of the metastate properties of business objects are bindable in the current versions of CSLA.

You should use ViewModelBase to access bindable versions of these properties, as shown in the video series and ebook series.

patelravij@gmail.com replied on Tuesday, April 17, 2012

Thanks for your replay.

I have created a dependency Property in ViewModel and added Event handler BrokenRulesCollection.CollectionChanged for businessbase object property. Then set dependency property in event by checking count of brokernRules and bind with IsEnable property of the search button 

 

 

if (this.Criteria.BrokenRulesCollection != null && this.Criteria.BrokenRulesCollection.Count != 0)

{

this.CanSearch = false;

}

else

{

this.CanSearch = true;

}

 

 

Its works fine.!!! But is it proper way achieve above scenario? 

RockfordLhotka replied on Tuesday, April 17, 2012

You can look at the implementation of the various properties (like CanSave) in the ViewModelBase class in Csla.Xaml. There are some tricks to making these properties work correctly - and they don't need to be a DependencyProperty - just a bindable property that raises PropertyChanged.

Copyright (c) Marimer LLC