XAML Part VII: Fun with markup compatibility

If you misspell an attribute name in an HTML document the browser will simply ignore it. For example, if you spell the href attribute as zhref the <a> tag the attribute will be ignored. For example, this is text is in such an <a> tag. It is displayed like a link but it doesn't go anywhere because it doesn't contain an href attribute. Intentional misspellings can be used to temporarily comment out an attributes or an element. XAML doesn't support this technique directly. If you misspell an attribute or an element the XAML parser will emit an error message and refused to produce a BAML file or load the document dynamically. This is the behavior you want if you unintentionally misspelled an attribute. The compiler will tell you exactly where the error is and you can quickly find and fix the problem. But temporarily commenting out an attribute can sometimes be useful when experimenting or prototyping. XAML provides a way to duplicate the this commenting out technique through the use of the markup compatibility namespace. Markup compatibility tells the parser which namespaces are not required to be recognized when loading a XAML document. If you declare a namespace that will never be recognized, such as "Comment", you can use that namespace to comment out items by using its prefix. For example, let say you want to see the effect of removing the Width property of a Button but not lose the value it currently has which would happen if you simply deleted it. Consider the following,

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> 
  <Canvas>
    <Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50">
      Hello
    </Button>
  </Canvas>
</Window>

To comment out the Width attribute you can add the markup compatibility namespace, then an unknown namespace, and finally declare the unknown namespace ignorable. This might look like,

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c="Comment"
    mc:Ignorable="c">
  <Canvas>
    <Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50">
      Hello
    </Button>
  </Canvas>
</Window>

You can then comment out the Width and Height attributes,

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c="Comment"
    mc:Ignorable="c">
  <Canvas>
    <Button Canvas.Top="50" Canvas.Left="50" c:Width="100" c:Height="50">
      Hello
    </Button>
  </Canvas>
</Window>

You can even comment out the entire Button with,

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c="Comment"
    mc:Ignorable="c">
  <Canvas>
    <c:Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50">
      Hello
    </c:Button>
  </Canvas>
</Window>

I only recommend this when you are prototyping. You shouldn't have commented out text in production XAML files. Fortunately, this technique makes it easy to determine if you have removed all such commented out items. Simply delete the xmlns:c and mc:Ignorable declarations from Window. The compiler will now generate and error if you haven't removed comment prefixes. Finally, this technique makes it clear to any reader (both mechanical and human) that you intended to comment out this property, you simple didn't just misspell it.

August CTP of Cider

Another month and another version of Cider. The August CTP is now available here. You can read the release notes and so forth from Channel 9 here. Not only did we make substantial changes, a list of which can be found here, we also updated it to work with the new .NET Framework 3.0 RC1 available here.

OK, I know we released a CTP in July I didn't blog about, but it was substantially a refresh to the CTP available for June (and I am a lazy blogger). Yes, yes, I also realize it is September and not August. I am blogging about it in September because it has just become available. The reason we call it the August CTP and not the September CTP is complicated but you can probably guess at least one reason...

BTW, new and improved versions of stuff we removed from the main tree are slowing winding their way back. I will be a bit coy about them now so as not to steal the thunder away from the current CTP but some cool and exciting things are still to come.

As always, we really want your feedback so be sure to check out the discussion site here.

June CTP of Cider

We updated Cider to be compatible with the June CTP of WPF which is part of the June CTP of .NET Framework 3.0 (the new name for WinFX) and threw in some bonus bug fixes. Check out the new release here. The release notes can be found here and, as always, we really want your feedback. If you have questions or comments about Cider let us know here!

May CTP of Cider

We have announced the May CTP of Cider here and release notes and download instructions can be found here. Some highlights include,

  • A much, much improved Grid experience
  • It can handle a much larger set of XAML files but there are still some limitations we are working on for a future CTP.
  • Delete key support!

But we removed some things as well,

  • Document Outline support.
  • Zoom support.
  • Snap Lines.
  • Design support for StackPanel, DockPanel, and Canvas.

This reflects a quality focus on this release. We are transitioning, as a team, from a small incubation project to a production team. We are committing to be "close to ship" quality on all features we release to the public. The features we removed didn't qualify and we are working on bringing them up to snuff.

Cider's January CTP

Cider has been available since December in CTP form. This is really old news and reasons why I haven't blogged about it till now you can see my previous post about my and my machines independent vacations. To get the January CTP see the Channel 9 page http://channel9.msdn.com/wiki/default.aspx/Cider.JanuaryCTPReleaseNotes. You can keep track of our developments through our Channel 9 home page at http://channel9.msdn.com/wiki/default.aspx/Cider.HomePage. I will try to be better about timely blogging updates but given my past history maybe it would be better if you checked the home page now and then...

This month we are focusing on the grid design experience. Even though we shipped it in December we really stole, uh, er, borrowed the grid design experience from Sparkle (aka the Expression Interactive Designer) which is also now available in CTP form available from http://www.microsoft.com/downloads/details.aspx?familyid=ed9f5fb2-4cfc-4d2c-9af8-580d644e3d1d&displaylang=en.

The Cider CTPs are not beta quality. I say that to make sure you know what to expect. We are delivering bits early and often to give all of you a chance to influence our development by giving us early feedback on our design and the general direction we are taking. I encourage all of you to take advantage of this. We are listening and care a lot about what you think.

More Cider at the PDC

Yet more Cider stuff. Brian and Mark tag teamed together at the PDC to present how to add design-time behavior to WPF (Avalon) controls. You can find their presentation here... (Maybe Corbin will be able to view this one ;-).

I seem to not be in any of the recent videos. I am really not that bashful. Here I am in the audience (Mark points to me). I wasn't on stage because I had to leave early to catch a plane. I will probably show up sooner or later in one of these.

Cider on MSDN

Mike Harsh and Mark Boulter demo'ed Cider for MSDN. Check it out...

Cider on Channel 9

Mark Boulter and Brian Pepin make an appearance on Channel 9 to explain and demo Cider. Check it out...

Cider architecture

Brian Pepin has started to blog about Cider's architecture. Check it out...

Cider demo'ed at the PDC

If you missed the PDC and Eric Rudder's keynote address where Cider was demonstrated you can watch it here. Mark Boulter demonstrates it with Joe Marini demonstrating Sparkle. Their part begins around 37 minutes into the keynote.

Cider is Announced

Cider is now announced! In case you missed it at the PDC, Cider is the code name for the Visual Studio Designer for WPF (pronounced Avalon according to Chris) that will be delivered in Orcas. We also announced the Expression product line that includes a different designer called Sparkle. Other than the obvious difference between Sparkle and Cider, Cider is in VS, Sparkle is a stand-alone product, Cider will be a designer for developers, Sparkle will be a designer targeted at professional designers.

For those that were asking about what I was working on, I wasn't trying to be coy, I just didn't want to spill the beans early.

I will be more forthcoming in the months ahead and try to keep you up-to-date with our progress.

If I missed you at the PDC, I am sorry about that. Feel free to ask your questions here or via e-mail (chuckj directed through microsoft.com).