Chooser Manager

The chooser manager allows exposes all choosers available on the Windows Phone 7 platform.  To use it just like any other manager within the project you can include the IChooserManager as a dependency within your View Model.  Each chooser has a completed and failed event handler you can attach to within your View Model and respond accordingly to the result.

A simple example of taking a photo would be as follows:

1. Include the dependency on your View Model.

   1: public MainViewModel(IChooserManager chooserManager)
   2: {
   3:     this.chooserManager = chooserManager;
   5:     this.WireEvents();
   6: }

2. Attach methods to your relevant events.

   1: private void WireEvents()
   2: {
   3:     this.chooserManager.TakePhotoCompleted += this.TakePhotoCompleted;
   4:     this.chooserManager.TakePhotoFailed += this.TakePhotoFailed;
   5: }

 3. Execute the chooser method.

   1: this.chooserManager.TakePhoto();

 That’s it! In the case above you will get a PhotoResult returned which includes the pictures filename and photo stream for you to work with in the TakePhotoCompleted method you have created.

Last edited Dec 17, 2010 at 8:31 AM by JonathanSharratt, version 8


No comments yet.