views:

145

answers:

3

How feasible is it(and some guidance) to build a WPF(Silverlight) app in such a way that it can be flipped back and forth from Web to Desktop?

Maybe some context is in order.

I am a lone developer at a non-profit. I only develop in house apps that have very long life cycles with constant modifications and changes to business rules or requirements. For example, my first project here was converting an existing ASP.net(2.0) app to a winform app to allow disconnected use in the field.

Now if I had only known then what I know(or think I know) now I probably wouldn't need to ask this but, I digress.

I recently was introduced to Silverlight 3 and the world of XAML at Twin Cities Code Camp and one of the presenters was using some UI code interchangeably from Silverlight to WPF.

Now, right off the bat, I know that Silverlight is a Subset and is not completely interchangeable. Never the less, it got me thinking. If I used WPF and re-wrote our core app from winform would that, in fact, enable me to use XBAPs and allow my app, with few changes, to be Web based and/or Desktop with on identical UI and Business Layer?

  • What considerations would I need to make to allow that kind of flexibility?
  • Any guidance sources any one can offer?

As a side note, 75% of all our apps are in some way, shape, or form variations of CRUD apps with a Central SQL Server as the data store.

I found the following article that also helped get the wheels turning, HERE


Edit

I really appreciate the responses and I definetely will be looking deeper into Silverlight's Out Of Browser functionality.

What my original question was trying to ask was how I would go about making my UI as 'flippable' as possible. I understand that the Out Of Browser MAY allow a one stop shop app but that asside would using XAML, in a certain way, allow me to reuse an identical UI for Web and Desktop apps?

On a tangent; Can anyone offer anything on Silverlight and some type of Replication?

+4  A: 

You should really take a look at out of browser silverlight apps. See this blog post: http://wildermuth.com/2009/03/18/Enabling%5FOut-of-Browser%5FSupport%5Fin%5FSilverlight%5F3

It seems like this might be exactly what you are looking for.

Note: That an out-of-browser Silverlight app is still fully sandboxed like an in-browser Silverlight application, unlike a WPF application which is full-trust and has complete access to the user's machine. Also, out-of-browser Silverlight apps do support "disconnected" use and provide APIs to determine network availability.

KeithMahoney
Silverlight OOB is exactly what you need.
Nate Bross
Really, this has me excited but please see my comment on Bryant's post.
Refracted Paladin
You can use Isolated Storage to persist data while in the offline state. This data storage is robust and won't ever be automatically cleared. However, the user *can* opt to delete data from the isolated storage area, but as long as they don't do that the data should be safe.
KeithMahoney
+6  A: 

It sounds like the best option for you would be to develop your applications in Silverlight and make use of the Out Of Browser (OOB) feature. The OOB feature allows you to install a Silverlight application on your desktop so that it can run in offline mode. You can make use of .NET RIA Services which includes the Business Application Template allowing you to very quickly create CRUD types of applications.

You will need to have a web services layer in front of your sql databases for this approach. However, that should be there regardless.

For data in offline mode you can use Isolated Storage (as Nate mentioned in the comments). Here are a few links on that topic:

On my current project we cache the lookup tables as collections in Isolated storage for offline mode. When the user comes online we refresh that data. For transactional data (like an order) we don't cache them, but we allow the user to create new ones offline and then add them to the system when they come back online. It is working well for us right now.

Bryant
At this point, how robust is the data in offline mode? The winforms version uses SQLExpress installed on each machine and using Merge Replication to sync the two db's, which I now recognize as severe overkill. How persistent is the storage? i.e. Shutting system down
Refracted Paladin
You get to use Isolated Storage. It should persist through reboots, etc.
Nate Bross
+2  A: 

An occaisonlly connected Silverlight app is going to be a bear to write. All you have for durable storage is Isolated Storage.

Same with XBAP.

Do you need cross platform support for your apps?

Why not just do a ClickOnce WPF app, and set it up to be able to switch between a live connection to a service layer and a disconnected mode?

Multi-targetting WPF and SL can be done, but it is not easy. Check out the Prism project which includes guidance and a VS add-on to support multi-targetting.

Bryan Batchelder