Project Description
WP7 Contrib is a set of components to help build WP7 Apps. It can be plugged into MVVM Light or used as separate components in your App. Our goal is to provide a set of tools and patterns that help WP7 developers.
Now available via NuGet -
http://nuget.org/List/Search?searchTerm=author%3A%20WP7ContribThe framework is built on top of the following framework & libraries:
MVVMLight Toolkit -
http://mvvmlight.codeplex.com SilverlightSerializer -
http://whydoidoit.com/silverlight-serializer/Json.Net -
http://json.codeplex.com/Reactive Extensions for .NET (Rx) -
http://msdn.microsoft.com/en-us/devlabs/gg577609 (Currently using version 1.0.10621).
Samples & Downloads
See documentation.
What's it all about ?
The WP7 Contrib (WP7C) is just like many other contribution community led efforts where there is a movement to bring resources together, solve common problems and help shape new ways of looking at common platform problems.
The WP7C contains not only work we have put together based on our development experiences for WP7 but also from the wider community. What we wanted to do was package all this up into a single place to make it easy for those people developing on WP7 to find and examples of how to use the pieces. The other reason is to inspire the community, encourage feedback for new feature requests and also have people join us on our quest, maybe even contribute some of their great work as well.
At the moment we are light on unit tests but we are working on improving coverage, so please bear with us on this, we understand how important these are. So, you may be thinking how can they be sure that all the code works ? We will be releasing very shortly into the Market place a number of applications that have been built using the bits contained in the Contrib. In the coming months we will publish blogs which will contain example recipes for using the WP7C we will also go deep on some of these topics and also discuss the future roadmap here.
You will see an underlying theme to all of the components that we are revving currently these approaches include; Use Rx where possible to help with performance when requesting data from endpoints; single responsibility; and ask don't tell patterns. Ollie will be going deeper on these topics with some up and coming blogs posts as to why we believe these approaches help with development practices in general.
We wanted to concentrate purely on WP7 development problems and steer away from building an MVVM Framework, therefore we made the decision (well Laurent had me in a headlock at the time :-)) to base our current implementation on MVVM Light. However, those dependencies are very loose we have subclassed the VM Base class to deal with Navigation and TombStoning, there is also a dependency on the IMessenger interface which is used in the implementation of our VM's. Our current thoughts are that with such loose connections swapping in your MVVM framework of choice should be rather straight forwards. So if there are enough votes and shouts we would be very interested in hearing them and working towards providing a solution for them.
Features
Caching
Our goal here is to provide a light weight solution to caching on the handset, we provide an interface defining a strategy with common functionality such as item access, addition, removal and expiry. There are different types of caching which have been catered for; in memory caching; and isolated storage. The whole purpose behind the Caching component is to define a caching strategy that is flexible for your content, we provide a couple of implementations but we expect there to be other implementations in the future.
Know doubt you have worked out that the WP7 device does not have the same processing power as your laptop or PC and therefore we need to provide a component which can deal with client side caching this will provide a mechanism to help reduce the calls made by a disconnected client; free up bandwidth; and help to improve performance in general.
The Isolated Storage Provider does what it says on the tin and is purely responsible for pushing content into isolated Storage as well as having an in memory representation. It utilises the SilverlightSerializer
http://whydoidoit.com/silverlight-serializer/ to persist and revive data from disc. As with all of the components contained within WP7Contrib we are using DI to inject these different interfaces into the VM and services that are being used by the application being built.
The In Memory Caching Provider is for caching in memory only , it is not persisted across application tombstoning or application restarts.
The Null Cache Provider incase you dont want to cache anything.
There are 2 patterns that have thus far have emerged, we will cover this off in more detail in a couple of blog posts.
First is the VM possibly the most obvious place, where by the VM is already responsible for managing state, logic and so the addition of identifying what content needs to be cached feels like a natural progression in the evolution of the VM and its responsibilities. Second, is down in the service layer where would historically associate a caching mechanism to be found. These 2 techniques used in combination help to solve the TombStoning problem. Watch out for a specific post around implementing TombStoning in you applications using the WP7 Contrib
Messaging
Replay Messenger is new messenger pattern to help solve the problems encountered when using a DI container for loading your VM's. Stay tuned for more posts on how to use the Messenger. In the meantime you may want to head over to MVVM Light
http://mvvmlight.codeplex.com to take a look at the implementation details or checkout Laurent's blog where you can find more details on the messenger and some of the baked in Messenger's he has already
http://www.galasoft.ch/mvvm/getstarted/
Collections
In the development of applications for WP7 we've utilised the Reactive Extensions for .Net
http://msdn.microsoft.com/en-us/devlabs/ee794896, specifically we've concentrated its use around the making of asynchronous calls to application & back-end services, this has lead to the requirement for a thread safe observable collection implementation, we also implemented a read only version as well.
To help with the handling of large amounts of data that can be returned from back-end services we have incorporated a definition of the IPagedCollectionView interface from the core Silverlight framework as well as interface IPagedList and implementation PagedListView. We'll be diving deeper into these in the future blog posts.
Services
Location Service provides location based information of the users device using the Reactive Extensions for .Net, this has allowed us to abstract away the GeoCoordinateWatcher class. We also paid attention to Jaime's points he makes here
http://blogs.msdn.com/b/jaimer/archive/2010/11/11/geocoordinatewatcher-tips-part1.aspxLogging Service provides a simple logging mechanism which uses isolated storage for persistence, we decided to make this as stripped down as possible, the current implementation provides the interfaces ILog & ILogManager, with the later designed for simple UI implementations inside an application.
Navigation Service provides a mechanism for manipulating the Root Frame allowing your VM's to control navigation. This implementation builds on the ideas from Laurent and the pnp WP7 development series.
Themed Resource Locator originate from pnp
Settings Service provides the ability to persist user settings.
Storage Service provides a mechanism for persisting content when an application is closed or TombStoned, it offers the ability to persist content to either in a persistent or transient store and utilises the SilverlightSerializer for internal serialisation before persisting in one of the two framework provided dictionaries - IsolatedStorageSettings.ApplicationSettings (persistent storage) & PhoneApplicationService.Current.State (transient storage).
Communications
Talking to back-end services specifically RESTful services requires the use of the classes WebClient, HttpWebRequest & HttpWebResponse and this can become a repetitive task, so we've provided an abstracted implementation that supports the GET, POST, PUT & DELETE over HTTP and returns all results via the Reactive Extensions for .Net
http://msdn.microsoft.com/en-us/devlabs/ee794896 interface IObservable<T>.
We've also provided an IObservable<T> implementation of a network connectivity monitor, so you can hook up a subscriber and get notified when the network type changes.
Diagnostics / Debug
The diagnostics project is designed to help enable logging and debugging at runtime. Using the WP7Contrib.Diagnostics.RunTimeDebug you can easily add diagnostics messages which can be sent via email or shown in the ui while not getting in the way of the ui. The RunTimeDebug tool is to enable developers to test application running on live devices, as well as build in crash log support to production applications.
see screencast example:
http://download.codeplex.com/download?ProjectName=wp7contrib&DownloadId=205341
UI Controls
BehaviorsThe behaviors originate from our good buddy Stuart Harris over at Red Badger who came up with some rather cool behaviors that can be applied to App Bar Buttons that allow you to wire up Relay Commands to the buttons, you can get more details here
http://red-badger.com/Blog/post/Watching-Silverlight-Dependency-Properties-with-Reactive-Extensions.aspx#commentBinding ListenerThis originate from the PNP WP7 developer framework, but was then refactored by Stuart as he found memory leaks.
http://red-badger.com/Blog/post/Watching-Silverlight-Dependency-Properties-with-Reactive-Extensions.aspx#commentConvertersThis is a starting point really there are a ton of great coverters out there and its a case of harvesting these up at the moment there are a couple of my favourites.
DateTime PickerThis is a customised version of the one found in the toolkit, however this version allows you to customise the number of selectors you want to be visible.
ExtensionsThese are taken from the PNP WP7 developer framework and have some very useful extensions when building WP7.
HelpersA set of various helpers taken from PNP WP7 developer framework and other resources on the internet.
OrientationA set of various helpers take from the awesome work done by David Anson that animate the Root Frame when changing orientation of the device
SlidersDave Reylea's performance slider
http://blogs.msdn.com/b/devdave/archive/2010/10/04/a-better-slider-for-windows-phone-7.aspxRange Slider has been recompiled to work on WP7 that originates from Martin Grayson's Blacklight UI Controls
http://mightymeaty.members.winisp.net/blacklight.silverlight/ControlsThese are a collection of controls that we have found to be very useful that other members in the community have been working on.
TransitionsThese are taken from the work done by Kevin Marshall
http://blogs.claritycon.com/kevinmarshall/2010/05/12/windows-phone-7-prototype-002-animated-page-transitions-writeable-bitmaps/ along with some additional transitions to give parity with the SL toolkit