In my new app, I really wanted to provide the ability for users to crop an image that would be used for a background. I figured I’d have to create a custom control and maybe use the Nokia Imaging SDK and frankly, that sounded like a lot of work so I left this functionality out of my app thinking I’d go back and add it on the next release.

Maybe this is widely know, but it was news to me. To crop an image in the photo chooser on Windows Phone, all you have to do is set the pixel width and height that you want to allow and the crop tool pops up automatically. How cool is that? So easy. But, I searched quite a bit trying to find a solution and couldn’t. Then, I came across a StackOverflow post where someone explained it.

Here’s what the code looks like for the chooser (I’m actually grabbing the device screen size for my width and height).

private void uxPickPhoto_Click(object sender, RoutedEventArgs e) { _photoChooserTask = new PhotoChooserTask(); _photoChooserTask.PixelWidth = Convert.ToInt32(_screenSize.Width); _photoChooserTask.PixelHeight = Convert.ToInt32(_screenSize.Height) ; _photoChooserTask.Completed += _photoChooserTask_Completed; _photoChooserTask.Show(); }

That’s it. Once you add the pixel width and height, you get this nice crop tool, allowing users to select where the image should be cropped. I love when things like this are built into the native API.


Now the first release of my app will have image cropping.