×

First time here?

You are looking at the most recent posts. You may also want to check out older archives. Please leave a comment, ask a question and consider subscribing to the latest posts via RSS or email. Thank you for visiting!

On the heels of the Windows Phone Developer Tools and Silverlight for Windows Phone Toolkit releases I saw a lot of exhaling going on in the hallways today.  Apparently Jeff saved his largest one for an avalanche of knowledge on Twitter in the late afternoon.  Jeff Wilcox is a developer on the Silverlight team and has been working on the Silverlight for Windows Phone initiative as well as the toolkit released today.  He was headed out on vacation but decided to throw out some words of wisdom for Windows Phone developers working in Silverlight.  Here’s some of those nuggets – I wanted to capture them before he left because who knows how long they’ll stay in Twitter.  It reads like a true guide to developing great apps on Windows Phone…

  • Panorama looks nice, but Pivot will offer faster start time.
  • You can also set a Background image to a Pivot. You won't get the parallax effect, but it is another option.
  • Be aware of how many pano and pivot items you do have. Memory expands quick when you have a lot of views and images!
  • Even if you have a 30k compressed JPEG image, at runtime that becomes an uncompressed surface that may take several MBs of memory
  • Pivot and Panorama can have UI element headers and titles, too, but you'll need to apply your own styling (fonts and sizes)
  • Beware that UI elements larger than 2000x2000 pixels that are bitmap cached clip on Windows Phone 7. We know it isn't perfect, but beware k?
  • Setting SelectedIndex before the items are set on a Pivot causes an exception. Wrap in a try/catch or wait for loaded (sorry!)
  • A slideshow app in 5 minutes: Pivot with null Header and Title and item headers. Beware memory use though.
  • A lot of people try building 'wizard' screens with panorama & pivot control. Please don't do this! Thx, the "UX gods"
  • Layout is a killer. But like death, you eventually have to pay it for everything.
  • So consider delay loading controls and screens. A Panorama with a billion items will take forever to load due to layout.
  • If you're not using PerformanceProgressBar, I'll send @JustinAngel after you ProgressBar for Windows Phone 7
  • If your app rocks and starts really quick *on a device* consider not using a splash screen
  • It's true. Your 6-core machine running the wp7 emulator is NOT indicative of device (single core!) performance. Beware!
  • We've talked perf before... Content over Resources for images means fast startup time http://bit.ly/9DhVbd
  • If you're using Panorama, a Resource background will load immediately compared to Content
  • Remember that for ingestion to the marketplace, your apps need to consume under 90MB of memory
  • However on devices with > 256MB, its cool to use more *in those cases
  • long deviceTotalMemory = (long)DeviceExtendedProperties.GetValue("DeviceTotalMemory");
  • long applicationCurrentMemoryUsage = (long)DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage");
  • long applicationPeakMemoryUsage = (long)DeviceExtendedProperties.GetValue("ApplicationPeakMemoryUsage")
  • Your compositor thread should rock out around 60fps all the time please. #wp7dev perf counters: http://bit.ly/busJIi
  • If your UI thread gets pegged, your compositor thread will suffer... remember your BackgroundWorker kids!
  • Unfortunately the "Analytics" type from desktop Silverlight is not on the phone today, so you can't measure CPU in a regular app
  • Having a single DispatcherTimer in your app can affect your battery life regardless of interval. Chose wisely
  • You can set the Foreground property on Pivot to set the title and header text color
  • Using a map control inside a Panorama or Pivot is not recommended for a number of UX and technical reasons. Navigate to a subpage.
  • Please use text styles and never hardcode sizes or default fonts.
  • The panorama/pivot items expect most their contents to have a 12px margin left/right for UX reasons. The default styles have this.
  • So if you have something in a pano/pivot item with 0 margin & padding, your UX will be funky
  • Fill rate is super important. Keep it under 2.5 please
  • What is fill rate? 1.00 means one screen of pixels being rendered every frame.
  • Check your apps for extra, un-needed background colors on pages, controls, etc.. They impact perf.
  • That sexy "tilt" effect? Use Peter's behavior http://bit.ly/90Z1yR and/or check out the MSDN docs
  • DataTemplates with a bunch of StackPanels and Grids? Try to simplify to a Grid with the right col/rows instead for perf wins.
  • Unit testing in a quick and dirty way is possible on the Windows Phone thx to the sl unit test fx. http://bit.ly/a0DWah
  • Only use Dispatcher.BeginInvoke when you must. Look at SmartDispatcher (ps old code sry) http://bit.ly/axHh36
  • For a "wide" Panorama item, set the item's Orientation to "Horizontal"
  • Play with the cache and redraw vis. settings to see what's being cached in your app http://bit.ly/busJIi
  • Things in a list/scroll viewer are often automatically bitmap cached by Silverlight for Windows Phone runtime
  • If you have a progress bar with IsIndeterminate="True" in your app, even if its hidden those storyboards are costly! Set to False!
  • We did work on Windows Phone 7 to move more networking to the background thread - hope it helps
  • When a Panorama loads, all its items go through a render pass. For pivot, it is done incrementally for neighboring items.
  • When making web requests, see if the service lets you scope down the fields that are returned for quicker perf (and JSON over XML!)
  • If you navigate to a subpage, the old page will stick around - so complex pano/pivot pgs stay in memory unless you're proactive
  • The "app deployment tool" installed with the dev tools lets you run others apps in emulator/device without needing source
  • We optimize for loading some things from isolated storage. Images from an isostore stream may load faster than a MemoryStream
  • If your source files have "Black" or "White", you might be doing it wrong. PhoneForegroundBrush, PhoneBackgroundBrush instead!
  • If your control's dep. property has a change handler, animating that prop. will always happen on the UI thread (no gpu accel.)
  • Animating Opacity on a CacheMode="BitmapCache" element = compositor thread (GPU!)
  • In the RTM tools, scroll viewers all have the "bounce" effect automatically
  • If you ignore the phone's theme (and go all light bg, like the mail app), your scrollbarsmust be retemplated or you won't see them!
  • Although data binding is not evil, an observable col. with a complex data temp. and 200k items is evil.
  • The web browser control won't let you NavigateToString until it has loaded.
  • If you have an app with a lot of different web browser controls, think about consolidating to one, so it only has to load once.
  • Panorama is designed to be a starting place. Think whitespace. Not tons of data
  • Free performance win: when you use Panorama the way the UX guidelines recommend, it is faster! http://bit.ly/9zTxtU
  • Those theme xamls for #wp7? Yeah they are in %ProgramFiles%\Microsoft SDKs\Windows Phone\v7.0\Design\
  • Resist the urge to Panorama every app.  It is a sweet UX thing when used right…but not just because.
  • Resist the urge to iPhone gradient your apps. Think outside the box! Also it avoids color banding...

So as you can see, he sort of knows what he’s talking about :-).  Go subscribe to his blog and follow him on Twitter.  Other helpful links:

Thanks Jeff for sharing your awesomeness!

Hope this helps!


This work is licensed under a Creative Commons Attribution By license.


9/16/2010 8:37 PM | # re: Windows Phone 7 Developer Tips and Tricks
was fun watching all the developers on twitter go back and forth during Jeff's spewing of information - now to try and digest it all.

thanks for saving it all
9/17/2010 1:33 AM | # re: Windows Phone 7 Developer Tips and Tricks
JSON over XML makes sens in terms of amount of data but what about the serializer / deserializers perf ?
9/17/2010 2:00 AM | # re: Windows Phone 7 Developer Tips and Tricks
Janki, have you investigated the ICollectionView for visual List reordering ?

It gives some pretty cool stuff to reorder your list without touching the binding source.
9/17/2010 2:09 AM | # re: Windows Phone 7 Developer Tips and Tricks
Gold dust!

I didn't get "If you're not using PerformanceProgressBar, I'll send @JustinAngel after you ProgressBar for Windows Phone 7"

Have the ProgressBar perf issues been addressed in the latest drop - or do we need to continue to use Jeff's PerformanceProgressBar?

Cheers,
Jason
9/17/2010 7:31 AM | # re: Windows Phone 7 Developer Tips and Tricks
@Jason,
As addressed in the PerformanceProgressBar post, the underlying inability to offer relative animations in the Silverlight platform still exist - there was no way to address the ProgressBar issues for the RTM release unfortunately.

The PerformanceProgressBar is still needed today.
9/19/2010 2:10 AM | # re: Windows Phone 7 Developer Tips and Tricks
Great list, thanks!

With regards to XAML, would a user control (or any control) with it's visibility property set to collapsed (it's not a ProgressBar!) be rendered/processed?

Is it better to programatically add the control after you've worked out whether it's needed or not?
Or always have it there but bind the Visibility property (would be easier)?
Or does it make little difference?
11/2/2010 6:49 AM | # re: Windows Phone 7 Developer Tips and Tricks
Regarding this point:

"- Beware that UI elements larger than 2000x2000 pixels that are bitmap cached clip on Windows Phone 7. We know it isn't perfect, but beware k?"

I have a large TextBlock inside a ScrollViewer (actually with some intermediary containers in-between, not directly), which i remember that automatically bitmap caches its contents, something i really want to avoid in this situation (monstrous memory consumption + clipping of the text), but i just can't override that bitmap cache setting. Can anyone suggest me how to do it ?

Thanks in advance.
11/11/2010 6:47 AM | # re: Windows Phone 7 Developer Tips and Tricks
nice tim . thnx 4 sharing
javaScript tutorials

11/26/2010 11:15 AM | # re: Windows Phone 7 Developer Tips and Tricks
"Be aware of how many pano and pivot items you do have. Memory expands quick when you have a lot of views and images!"

Why is this? Why can't pivot only have the current, previous, and next items in memory at any given time? I'm sure you've seen people make a simple photo slideshow with it before, but apparently, it wasn't designed for this. It seems like it loads them as you scroll, but the items are never taken out of memory after they are created, which doesn't sound very optimal to me. Am I missing something, or was it just never designed for very many items?
9/11/2011 11:15 AM | # re: Windows Phone 7 Developer Tips and Tricks
These tips for Windows Phone 7 are very helpful for me, your every post provides a great collection of latest information. I wish you continue the same work in future as well. Thanks Orchid Recovery Linkedin
9/16/2011 3:25 AM | # re: Windows Phone 7 Developer Tips and Tricks
That is one impressive list of tools there, some really awesome some in there.
James - gadget blog

 
Please add 7 and 6 and type the answer here:

DISCLAIMER:

The opinions/content expressed on this blog are provided "ASIS" with no warranties and are my own personal opinions/content (unless otherwise noted) and do not represent my employer's view in any way.