Skip to content
wpdev

.NET / C#

Windows Phone 7

Storage bug in MediaLibrary.SavePicture

2013-05-26
By: Kevin Gosse
On: May 26, 2013
Tagged: .NET, C#, Windows Phone 7, Windows Phone 8, wpdev

I’ve received many reports lately of users complaining of abnormal storage usage from one of my apps, Imageboard Browser.The application was in some cases storing hundreds of megabytes! I thought at first that it was just the “other storage” issue, but I did some further investigation just in case. After some trial and error and a bit of luck, I’ve discovered that the bug lies in the methods MediaLibrary.SavePicture and MediaLibrary.SavePictureToCameraRoll. As their name indicate, they are used to save a picture to the phone’s picture hub, and they do their job pretty well. Except that ever time you use them, a copy of yourRead More →

Memory leak with BitmapImage

2013-02-17
By: Kevin Gosse
On: February 17, 2013
Tagged: .NET, C#, Memory, profiling, Silverlight, Windows Phone 7, Windows Phone 8, wpdev

There’s a memory leak that has been bothering me for a while in my Imageboard Browser app. The scenario is simple: a slideshow feature, where a new picture is loaded from an url every few seconds. After a while, the app crashes with an OutOfMemory exception. I’ve never been able to find the source of the leak, so I settled for a dirty workaround consisting in loading a fake picture in the BitmapImage instance to force it to release the memory: It fixed the issue, but I didn’t dig much further. However, over the last few weeks I’ve seen many similar leaks reported on StackOverflow,Read More →

Dynamically toggle PanoramaItem visibility

2012-07-01
By: Kevin Gosse
On: July 1, 2012
Tagged: .NET, C#, Silverlight, Windows Phone 7, wpdev

A strange issue with the Panorama control, that has been brought to my attention by @lancewmccarthy, and which has also been encountered by some people on StackOverflow. The original scenario was a bit too complex for a blog post, but we can reproduce it in a much simpler way. Create a new page, and add a panorama control called ‘Panorama’. Then add two PanoramaItem, and put a button in the first one: In the click event handler of the button, we toggle the visibility of the second item of the panorama: Start the application, try tapping on the button, and the visibility of the PanoramaItemRead More →

IsolatedStorageException when opening a file played by a MediaElement

2012-05-06
By: Kevin Gosse
On: May 6, 2012
Tagged: .NET, C#, Silverlight, Windows Phone 7, wpdev

Today we’ll dig a little into Windows Phone’s base class library, thanks to a question I found on stack overflow. The problem occurs with this simple code, used to load a music file from the isolated storage, and play it with a MediaElement: When executed for the first time, this code works fine. When executed a second time with the same file, it throws an IsolatedStorageException: “Operation not permitted on IsolatedStorageFileStream”. There isn’t many situations where opening a file from the isolated storage will throw an exception. The main two reasons are: an invalid filename, or a file sharing issue. Since the error only occursRead More →

How to press the mouse on a control, and detect MouseLeftButtonUp on another

2012-01-08
By: Kevin Gosse
On: January 8, 2012
Tagged: .NET, C#, Silverlight, Windows Phone 7, wpdev

Another issue I found on StackOverflow, which is way more tricky that it seems. Let’s say we have a Silverlight WP7 application, and we want to add a drag&drop scenario. The user first taps an element, drags his finger to another, and raises his finger on another element. Easy enough! Just handle the MouseLeftButtonDown on each element, store which element triggered the event in a property, handle the MouseLeftButtonUp on each element, and then we have the originator and the destination! … right? Well, so I would have thought. Unfortunately, the MouseLeftButtonUp event will only be triggered if the ‘mouse’ left button (or your finger,Read More →

ApplicationBar flickering when the phone theme is white

2012-01-05
By: Kevin Gosse
On: January 5, 2012
Tagged: .NET, Silverlight, Windows Phone 7, wpdev

It’s an interesting issue I found on StackOverflow. Interesting because I often forget to test my applications using the Windows Phone’s white theme, so this kind of problem usually goes unnoticed until a user reports it. Create a simple WP7 application with a black background and an ApplicationBar. Add a button to toggle the bar’s visibility. The XAML should look like: And the ButtonClick method: Now launch the WP7 emulator, go in the settings, and set the phone theme to ‘light’. Then start the application, and try pressing the button: the application bar disappears as expected, but you may notice a quick white flickering. TheRead More →

Recent Posts

  • Uncovering a bug in Attribute.GetHashCode
  • [UWP] NavigationService with back button handler priority
  • [UWP] Bandwidth adaptive image control
  • [uwp] Animation orchestration using Caliburn.Micro coroutines
  • Should I await the last call in a method

Archives

  • March 2017 (1)
  • February 2016 (1)
  • January 2016 (1)
  • October 2015 (1)
  • September 2015 (2)
  • August 2015 (1)
  • May 2015 (1)
  • April 2015 (1)
  • March 2015 (3)
  • October 2014 (1)
  • September 2014 (1)
  • November 2013 (1)
  • August 2013 (1)
  • May 2013 (1)
  • February 2013 (1)
  • December 2012 (1)
  • October 2012 (2)
  • July 2012 (1)
  • May 2012 (1)
  • February 2012 (1)
  • January 2012 (4)

Follow me on Twitter

My Tweets

Designed using Dispatch. Powered by WordPress.