Data binding User Settings in Windows Phone applications

 image

The canonical example of user settings is a “Show this welcome screen at startup” checkbox so that your application can offer a nice out-of-box experience.

By writing a simple type with some properties, adding a few helper files, and setting up a two-way data binding, you can store any settings without having to write special code.

Here’s what the completed project’s two-way data binding looks like for the checkbox:

  1. <CheckBox
  2. IsChecked="{Binding Source={StaticResource MySettings}, Path=IsFirstRun, Mode=TwoWay}"
  3. Content="Show this page at startup"
  4. />
  • Source is a static resource, a strongly typed settings class you define
  • Path points to the property name to bind to
  • Binding is two-way so that the value is stored automatically
  • Value and type converters can be applied as always in bindings if necessary
Creating your configuration/settings type

Next, we need to create a strongly typed configuration class that derives from my SettingsProvider type. This class must:

  • Implement INotifyPropertyChanged, so that bindings work well
  • Have properties of the appropriate type for the settings you are interested in. Optionally, include the DefaultValue attribute to provide defaults.
  1. using System.ComponentModel; 
  2. using JeffWilcox.Settings; 
  3. namespace Sample 
  4. /// <summary>
  5. /// My settings class for storing application data and setting specific to
  6. /// the user.
  7. /// </summary>
  8. public class MySettings : SettingsProvider 
  9.     { 
  10. private bool _isFirstRun; 
  11. private string _hello; 
  12. public MySettings() : base("MySettings.xml") { } 
  13.         [DefaultValue("What's up?")] 
  14. public string HelloWorld 
  15.         { 
  16. get { return _hello; } 
  17. set
  18.             { 
  19.                 _hello = value; 
  20.                 NotifyPropertyChanged("HelloWorld"); 
  21.             } 
  22.         } 
  23.         [DefaultValue(true)] 
  24. public bool IsFirstRun 
  25.         { 
  26. get { return _isFirstRun; } 
  27. set
  28.             { 
  29. bool old = _isFirstRun; 
  30.                 _isFirstRun = value; 
  31. if (value != old) 
  32.                 { 
  33.                     NotifyPropertyChanged("IsFirstRun"); 
  34.                 } 
  35.             } 
  36.         } 
  37.     } 

Via Jeff Wilcox – Data binding user settings in Windows Phone applications

A guide to what has changed in the Silverlight 4 RC

This is not all-inclusive, but I think a list of some that most will want to know about.

Changed

New

Via A guide to what has changed in the Silverlight 4 RC

Silverlight 4 Training Course

image

The Silverlight 4 Training Course includes a whitepaper that explains all of the new Silverlight 4 RC features, several hands-on-labs that explain the features, and a 8 unit course for building business applications with Silverlight 4. The business applications course includes 8 modules with extensive hands on labs as well as 25 accompanying videos that walk you through key aspects of building a business application with Silverlight. Key aspects in this course are working with numerous sandboxed and elevated out of browser features, the new RichTextBox control, implicit styling, webcam, drag and drop, multi touch, validation, authentication, MEF, WCF RIA Services, right mouse click and much more.

Visit http://channel9.msdn.com/learn/courses/Silverlight4/

5 Steps Toward jQuery Mastery

 

Most of us get our first taste of jQuery by implementing a simple animation effect or using a plugin for a specific purpose. This is natural because, like JavaScript itself, jQuery lends itself to beginning with the basics and building from there.

As you branch out from the trivial and begin using jQuery for more complex solutions, it’s important that you stay vigilant for new ways to approach those more involved problems. What works well enough for a dozen lines of code may not work for hundreds, and the unforgiving cross-platform environment that comes along with developing for web browsers only magnifies any trouble you run into.

With that in mind, I want to share a few tips with you that I found valuable as my work with jQuery became more complex.

  • Use Firebug to experiment interactively …
  • Cache selector results …
  • Don’t use jQuery unless there’s a good reason to …
  • Learn advanced selectors, filters, and traversals …
  • Use CDN hosting when available …

Goto 5 Steps Toward jQuery Mastery | Encosia for details