I would encourage you to use DataProvider. It will make
data binding easier in SL as well as easy to bind to Busy Animation. You code
will work, but you cannot bind to anything, unless you do it manually in your handler.
Sergey Barskiy
Principal Consultant
office: 678.405.0687 |
mobile: 404.388.1899
Microsoft Worldwide Partner of the Year | Custom
Development Solutions, Technical Innovation
From: James Thomas
[mailto:cslanet@lhotka.net]
Sent: Friday, January 30, 2009 4:56 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] CSLA for Silverlight - what's wrong with this
code?
Any chance someone knowledgeable could take a quick look?
I'm not sure it's quite right - nor how I can get 'busy' animations integrated.
tia, james.
btw, there's nothing wrong with your code James. It is totally acceptible to have the UI interact directly with the factory methods, providing a callback or event handler to process the result.
For that matter, you can skip the factory methods entirely and have the UI interact with the data portal - though personally I think that's less than ideal because you lose a level of abstraction.
Sergey is right though, in that we worked very hard to make the CslaDataProvider the simplest model. Not that we're attached to the data provider necessarily, but I think it is absolutely the case that in a XAML-based world you want to have as little code-behind as possible. Ideally that means writing NO code-behind at all, and that's certainly what I'm driving for.
There are two main areas left to address: authorization and exception handling.
I think a Csla.Silverlight.ExceptionDialog control can solve the exception issue. Such a control could be a resource on the page, and the data provider's DataChanged event could route to it. The result would be a messagebox (or something) on any data provider exception - all without code-behind.
Authorization is harder, because neither .NET nor Silverlight have a standard notification scheme to tell your code when the current principal has changed. And that's the primary trigger for re-running authorization logic.
But at least within the confines of Csla.ApplicationContext.User I can solve that problem and provide the notification, so there's some hope. That'd eliminate the need to have any code-behind to deal with most authorization scenarios as well.
In the end, I really think the goal must be to have zero* lines of C#/VB in any XAML UI - just XAML binding to objects and that's it.
* other than "scripting" style UI code - the kind of thing a designer might write behind some XAML to do animations or other UI-ish stuff; and even that is mostly a XAML thing now, so there should be very little of that either
Copyright (c) Marimer LLC