Vincent Leung .NET Tech Clips

The latest tech clips from the .NET community

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

April 6, 2010 Posted by | Phone | Leave a Comment

A few Quick Start Videos for Windows Phone Development

image 

  • Getting started with Silverlight and Windows Phone development
  • Windows Phone Application Bar
  • Navigation framework for Windows Phone applications
  • Custom application splash screen

    Via Getting Started with Silverlight and Windows Phone 7 Development

  • April 6, 2010 Posted by | Phone | Leave a Comment

    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

    April 6, 2010 Posted by | Silverlight | Leave a Comment

    More Silverlight 4 Learning Resources

    Learning resources suggestions:

    April 6, 2010 Posted by | Silverlight | Leave a Comment

    Building a Windows Phone 7 Twitter Application using Silverlight

    image image

    Via http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx

    April 6, 2010 Posted by | Phone, Silverlight | Leave a Comment

    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/

    April 6, 2010 Posted by | Silverlight | Leave a Comment

    An awesome Powerpoint presentation on Windows Azure Platform

     

    I just ran across a PowerPoint presentation by a colleague, David Chou, that is just plain awesome.  Check out this deck on the Windows Azure platform.

     

    April 3, 2010 Posted by | Azure | 1 Comment

    Visualizing large code bases with VS2010

    Chris Lovett posted a *great* 20 minutes video on how to use custom “Generate Dependency Graph” to manage larger code bases with the new visualization tools in VS2010.

    image

    Via Skinner’s Blog : Visualizing large code bases with VS2010

    April 3, 2010 Posted by | Architecture, VS2010 | Leave a Comment

    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

    April 3, 2010 Posted by | jQuery | Leave a Comment

    Follow

    Get every new post delivered to your Inbox.