How to bind WPF New button to AuthorizationRules.CanCreateObject?

How to bind WPF New button to AuthorizationRules.CanCreateObject?

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


Russ posted on Thursday, November 06, 2008

I have created a WPF form that contains a toolbar and a listview that is bound to a ReadOnlyListBase. The toolbar has a "New" button and a "Delete" button. I am using CSLA 3.5.

I am trying to find a way to:

1) bind the IsEnabled property of the "New" button to the Csla.Security.AuthorizationRules.CanCreateObject(typeof(Widget)).

2) bind the IsEnabled property of the "Delete" button to the Csla.Security.AuthorizationRules.CanDeleteObject(typeof(Widget)) AND ListView.SelectedItems.Count > 0.

I would prefer to code this in XAML and I am trying to avoid creating an unnecessary instance of Widget.

Any help would be greatly appreciated.

Thanks,

Russ.

RockfordLhotka replied on Thursday, November 06, 2008

I believe we addressed this in 3.6 by adding properties to the ObjectStatus control. You can put an instance of ObjectStatus as a resource on your page, bind it to the CslaDataProvider, and then bind your various UI elements to the properties of ObjectStatus.

We might have added them to the CslaDataProvider too, but I don't remember for sure. We did on Silverlight, and I'm not sure if we did the same in WPF.

I don't think the per-type authz properties were exposed in 3.5 (though I could be wrong).

Russ replied on Thursday, November 06, 2008

Thanks for the quick response Rocky.  I'll get started migrating my project to 3.6b2a.

Russ.

Copyright (c) Marimer LLC