Memory leak using Interaction Triggers on loaded event with MVVM light

Doing the following causes a memory leak and means the page that it appears on is not garbage collected:

<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<ex:EventToCommand Command="{Binding LoadedCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>

I found this whilst doing some WP7 development, using the normal Loaded event does not cause an issue. It is detectable by calling GC.Collect() on the destination page and checking to see if the finlize of the previous page is called. I found the finalizer was called N times only when I quit the app (where N is the number of times I had navigated to the page).

Since the phone apps are torn down if they exceed 90MB it’s a bit more noticeable.

WP7 low profile image loader

WP7 MonthYear Picker

For credit card expiry dates I needed to mod the Microsoft.Phone.Controls.DatePicker to only ask for Month and Year.
 
This was surprisingly convoluted but thanks for reflector, achievable. The xaml for the existing date picker is a resource in the dll but you do have to do a fair amount of work to keep it happy that it doesn’t have a day part anymore.
 
Seems to work and we’re on track for submitting the app tomorrow! 🙂

WP7: Disabling sleep

Whack the following in App_Startup:
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

Of course you should implement your own user idle detection. It would be nice if we could simply hook into a BeforeSleep event and stop it if we need to.