Dealing with deactivation during navigation.

Hi,

Probably every WP7 developer had to deal with this nasty issue.

Steps to reproduce:
During navigation deactivate app via central hardware button (Win). Important: Reproduces only on Device

Issue:
After activating app back InvalidOperationException with message “Navigation is not allowed when the task is not in the foreground” is thrown and navigation is not processed correctly.

Workaround:

After restoring app from dorment/tombstone it retries navigating  if navigation has failed (yeah, quite simple solution).

It is used like that:
Image

NavigationFixService.cs –¬†https://www.dropbox.com/s/oq0mdjg371y7vvj/NavigationFixService.cs?m

Funny difference in DP value inheritance between WP and WPF

Hi,

Have a look at the code. Try to guess

1. What color will be used to render text “Hello world” initially ?
2. Will it change after button click ?

Image

Answer:

Initially it will be yellow (yeah, it was easy). But after button click in WPF text color will change, but in SL for Windows Phone it won’t.

Explanation (actually not)

Basically i don’t understand this difference. I feel that this is a bug in Silverlight.
When we set foreground of a
1. ContentControl Рthe value gets inherited by TextBlockButton (TextBlockButton Foreground value is a new brush now), but notification is not sent to TextBlockButton template children (TextBlock) and TextBlock still uses old brush.
2. TextBlockButton – the notification is sent to its template children and text color changes.

Workaround:

Remove TemplateBinding for Foreground on TextBlock in ControlTemplate