On my WPF interface I have, amongst other things, a checkbox, and two textboxes. When the checkbox isn't checked then I would like the two checkboxes to be blank and disabled. Then if the user checks the checkbox, the two checkboxes will become editable.
My question is, where do I put the logic for this?
I'm using VS2010, with CSLA 4, and WPF using MVVM.
I know I can link the enabled property of the textboxes to something on the viewmodel, but I'm not sure whether I should just hard code it in the viewmodel or if it's possible to set up a rule on the business object that does it, and that I can then use to set the enabled properties.
This is exactly what custom authorization rules are used to implement.
If you implement this through custom authorization rules, the CanWrite property of your PropertyStatus or PropertyInfo controls will expose the results as bindable values, and then you just bind the UI controls' IsEnabled properties to CanWrite. The enable/disable becomes automatic.
Custom authorization rules are discussed in the Using CSLA 4: Creating Business Objects ebook.
Hi,
A couple more things to remeber:
public overide bool CacheResult
{
get { return false; }
}
You could also look at BusinessRuleDemo project in Samples\Net\cs\BusinessRuleDemo on how State is required if country is US. (Albeit WinForms the concept in the BO is just same for WPF).
Copyright (c) Marimer LLC