How to: Create a Simple Binding, reviewing the article on MSDN

An example article, if you read the article for Framework 4.0, would be: How to: Create a Simple Binding, first of all tere is a mention of a SDKSample.  But there is no sample on the page.  That is because the sample is included on the article for Framework 3.0 and Framework 3.5, which you have to use the drop down next to Framework 4.0 to find.  Then it is in the middle of that page. 

It’s a typo, but can waste your time if you try to work with the article as written. 

Then when you get the sample running, if you aren’t careful the sample will need to be unblocked because it is downloaded from the internet, and the files are unsigned.

Ok, the “How To: Create a Simple Binding” shows the necessary XAML, but neglects to show the class.  How does the class work with the XAML?

First of all the class isn’t a code behind module that you might have used in earlier study or exploration, it is simply a class.  In the example


is one of the lines of XAML, and can misbehave.  First of all the letters src, as I have mentioned in another blog, could be replaced with any word, even pineapple.

When you use the form: image, if all goes well you will see the objects in the related class file in a little intellisense file, like what is in the image.

The sample code does not come with a SLN file that will automatically load the files, it only comes with a CSPROJ. In this case, make sure to unblock the files, and load the project into your Visual Studio environment, make sure to load the csproj, once it loads in, all the other files load in as well and your references are set-up nicely.  If I recall correctly, the upgrade wizard runs as well since the version for the files are Framework 3.0.

The class implements the following class and interface.  The event INotifyPropertyChanged, which has a single event: PropertyChanged.


In the PersonName property, I changed the Set to show the length of the string:

public string PersonName
          get { return name ; }
              name = "Length " + value.Length;
              // Call OnPropertyChanged whenever the property is updated

Hope this helps. Smile

Comments (3)

  1. It didn't help says:

    So did you forget to discuss OnPropertyChanged?  That seems important.  Nice that you found the sample missing, but couldn't you talk about the important point: OnPropertyChanged.  How do you use it?  

  2. SnappyHeadedSnake says:

    Thans for the samle finding.  I couldn't get examle woring and now i cna.  cna't figure out the OnPropertyChanged event to wor.

  3. SoCal Sam says:

    Good comments, kind of quick though, how did "It didn't help" and "SnappyHeadedSnake" read this blog so fast?

    First of all "It didn't help" I am working on blog for OnPropertyChanged.

    SnappyHeadedSnake, it appears that your keyboard may need to have the p and k keys cleaned, but you are definitely welcome and glad I could help out.

    Actually is this some of my students at CSUDH goofing around?  Well if it is, keep up the good work, but use your real names for reasons we discussed in class.