Sonntag, 29. August 2010

Windows Phone 7: Tombstoning Bug with different assemblies for data contracts

If you are using different assemblies for your Windows Phone 7 application and your data / model which you wnat to be thomstoned then you get a “using unknown type” exception, if you come back to your Windows Phone 7 application. The reason for this ist, that the current Windows Phone 7 SDK has the bug that after thombstoning only the application assembly will be loaded. This bug will be fixed in the release :-)

The workaround for this problem is to put your data / model classes which will be used for thombstoning in the Windows Phone 7 application assembly.

Hope this tip will help anybody – it costs me nearly a day……

Silverlight: Increase performance for NotifyPropertyChanged

Last week I met Jeff Wilcox from Microsoft in my new Windows Phone 7 project for a big Telephone company in Germany. He gave us the following tip for improving performance of Silverlight applications concerning the often using NotifyPropertyChanged method. The tip is to store the event arguments in a dictionary to avoid the recreation every time.

 

   1: private static Dictionary<string, PropertyChangedEventArgs> _argumentInstances = new Dictionary<string, PropertyChangedEventArgs>(); 
   2:        
   3:        protected void NotifyPropertyChanged(String propertyName)
   4:        {
   5:            PropertyChangedEventHandler handler = PropertyChanged;
   6:  
   7:            if (null != handler)
   8:            {
   9:                PropertyChangedEventArgs args;
  10:  
  11:                if (!_argumentInstances.TryGetValue(propertyName, out args))
  12:                {
  13:                    args = new PropertyChangedEventArgs(propertyName);
  14:                    _argumentInstances[propertyName] = args;
  15:                }
  16:                
  17:                handler(this, args);
  18:            }
  19:        }

Dienstag, 24. August 2010

Windows Phone 7 – Integrate your App in standard picture viewer

With Windows Phone 7 you can integrate your own application seamlessly into the Windows Phone built-in photo viewer. The key to this feature is the Extras.xml file.

You have to place a new xml file with the name Extras.xml to your Windows Phone 7 project root. Set the properties to Copy to Output Directory and select Copy always.

   1: <Extras>
   2:   <PhotosExtrasApplication>
   3:     <Enabled>true</Enabled>
   4:     <StorageFolder>Incoming</StorageFolder>
   5:   </PhotosExtrasApplication>
   6: </Extras>

For the StorageFolder attribute you can choose your own name.

More informations you could find here: How to: Create a Photo Extras Application for Windows Phone

Sonntag, 22. August 2010

Windows Phone 7: Virtualization of the List control

One fantastic feature of Silverlight is that you can "virtualize" the UI objects needed to render a list, reducing the amount of memory and CPU necessary to load large lists. So you can bind a ListBox to 1.000.000 items, but you create only ListBoxItems for the first 100 items. This helps you to make your Windows Phone 7 App a little bit quicker if you want to work with large data lists.

The only thing you have to do is to derive your data source from IList. This fact triggers Silverlight to do data virtualization.

More informations about this feature you can found at Peter Torr’s Blog:

Virtualizing Data in Windows Phone 7 Silverlight Applications - Peter Torr's Blog - Site Home - MSDN Blogs

Samstag, 14. August 2010

High performance apps for Windows Phone 7

Here you could some very good tips to build high performace apps for Windows Phone 7 with Silverlight.

At compiledexperience.com they have a lot of new samples of Windows Phone 7 applications.

Dienstag, 10. August 2010

Windows Phone 7 – Emulator keyboard shortcuts

The Windows Phone 7 emulator has a number of shortcut keys that are good to know about:

The hardware keyboard can be toggled by pressing the Pause key, or opened / closed via the Page Up / Page Down key. The hardware keyboard closes the software one, so you can only use on at a time. When the hardware keyboard is open, a little icon is displayed on the top of the screen:

F1 on the keyboard equals to pressing the back button on the phone.

Pressing the F2 or the Windows key while the emulator has focus acts as if the phone’s Windows key was pressed. Continuously pressing it for a while brings up the voice command / search interface.

F3 works as the third physical button on the phone, bring up the Bing search.

F7 is wired to the physical camera button.

F9 and F10 raise and lower the volume. Pressing these brings up an interesting piece of UI, for controlling the currently playing music or radio, and switching the phone to vibrate.

F11 acts as the play / pause button. It is interesting that such a button is in the emulator as this button is not a required hardware button for Windows Phone 7 (WP7).