in

vbCity Blogs

New (temp) place for vbCity Blogs

CanOz Blog

Neil Knobbe's place for Visual Basic.NET and WPF

October 2008 - Posts

  • The Ampersand and XAML

     I got caught the other day with a "what the heck" moment.

    I was trying to display "Mr & Mrs" as an Item in a ComboBox but it just was not happening.

    I suppose that this would not have come to light if my computer was not slowing down when I opened the ItemCollection window in Visual Studio.  It was so slow that I would type something then have to wait for a couple of seconds to show what I had typed.  If I made a mistake I had to change it which would take more time, so I decided to just add the five combobox items in the XMAL itself.

    As soon as I typed the item in, I got the squiggly blue line and the following error.

     

     

    Which really threw me. 

    Being an old HTML boy from years past it finally hit me.  XAML is a markup language and most, if not all, markup languages use the ampersand (&) for defining special characters and XML (which XAML is based on) is no different.

    XAML has the same character entities as XML and one of these is for using the ampersand in markup.

    Having refreshed my memory getting the desired result was an easy fix.

     

    Which, when run, shows correctly in the ComboBox.

     

     

     

    Posted Oct 26 2008, 08:22 AM by CanOz with no comments
    Filed under: ,
  • Canoz's new home

     This is going to be the new home of my blog.

    I am going to be porting over some of the posts from my old blog, as well as writing new ones, so you may find that some of the posts you are seeing are familiar.

Copyright 1998-2009 vbCity.com LLC
Powered by Community Server (Non-Commercial Edition), by Telligent Systems