<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.0">
  <channel>
    <title>Removing All Doubt</title>
    <link>http://www.removingalldoubt.com</link>
    <description />
    <copyright>Copyright 2005 Chuck Jazdzewski</copyright>
    <lastBuildDate>Wed, 01 Nov 2006 13:55:23 GMT</lastBuildDate>
    <generator>ChrisAn's BlogX</generator>
    <managingEditor>chuckjaz@hotmail.com</managingEditor>
    <webMaster>chuckjaz@hotmail.com</webMaster>
    <item>
      <title>A Tour of XAML VIII: More fun with Markup Compatibility</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/defa2a7d-b1e9-49eb-b8c8-438348be8d18</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/defa2a7d-b1e9-49eb-b8c8-438348be8d18</link>
      <pubDate>Wed, 01 Nov 2006 13:55:23 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;In a previous post about markup compatibility I described how it can be used 
to enable
&lt;a href="http://www.removingalldoubt.com/PermaLink.aspx/12d47e2d-1767-4a3c-8802-3d5f0a624f66"&gt;
forward compatibility&lt;/a&gt; in XAML documents; documents that take advantage of 
features in, say, a 2.0 version of the document format but can also be viewed 
when only the 1.0 version is available. Using a technique similar
&lt;a href="http://www.removingalldoubt.com/PermaLink.aspx/301186e3-ec80-49ec-a2b0-2052dfa32d92"&gt;
the previous XAML post&lt;/a&gt;, we can also use &lt;span class="code"&gt;AlternateContent&lt;/span&gt; 
to get the effect of conditional compilation.&lt;/p&gt;
&lt;p&gt;Let say you want to have a label in a dialog that indicates that this is beta 
software so your customers will not confuse it with your production version. One 
way to accomplish this is to conditionally compile an &lt;span class="code"&gt;
XmlnsDefinition&lt;/span&gt; attribute into an assembly referenced by the project. When the conditional symbol is defined, the WPF XAML 
compiler will consider the namespace defined by the &lt;span class="code"&gt;
XmlnsDefinition&lt;/span&gt; attribute as known. If the conditional is not defined, 
the assembly will not have the &lt;span class="code"&gt;XmlnsDefinition&lt;/span&gt; 
attribute and the namespace will be considered unknown. This can be done by 
adding the following code to a referenced assembly,&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="code"&gt;#if BETA
[assembly:XmlnsDefinition("BetaVersion", "Example.Technology")]
#endif&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Remember, this must be an assembly referenced by the project, not in the 
project itself (I explain why below).&lt;/p&gt;
&lt;p&gt;You can then conditionally include a label, as in,&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre class="code"&gt;&amp;lt;Window 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"&amp;gt;
  xmlns:beta="BetaVersion"
  
  ... 
  
  &amp;lt;mc:AlternateContent&amp;gt;
    &amp;lt;mc:Choice Requires="beta"&amp;gt;
      &amp;lt;Label&amp;gt;
        This is BETA software. Do not distribute. 
        Use at your own risk.
      &amp;lt;Label&amp;gt;
    &amp;lt;/mc:Choice&amp;gt;
  &amp;lt;mc:AlternateContent&amp;gt;
  
  ...
  
&amp;lt:/Window&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;The label will only be included in the beta version of the assembly, not the 
production version (assuming that BETA is not defined for the production 
version, a mistake I have made before...). You can even make it more complicated 
by having other dummy namespaces for other versions and a fallback to catch when 
the build configuration was not correctly set up, such as,&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre class="code"&gt;&amp;lt;Window 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"&amp;gt;
  xmlns:alpha="AlphaVersion"
  xmlns:beta="BetaVersion"
  xmlns:production="ProductionVersion"
  ... 
  
  &amp;lt;mc:AlternateContent&amp;gt;
    &amp;lt;mc:Choice Requires="alpha"&amp;gt;
      &amp;lt;Label&amp;gt;
        This is ALPHA software. Confidential.
        Internal use only. Do not distribute
      &amp;lt;Label&amp;gt;
    &amp;lt;/mc:Choice&amp;gt;
    &amp;lt;mc:Choice Requires="beta"&amp;gt;
      &amp;lt;Label&amp;gt;
        This is BETA software. Do not distribute. 
        Use at your own risk.
      &amp;lt;Label&amp;gt;
    &amp;lt;/mc:Choice&amp;gt;
    &amp;lt;mc:Choice Requires="production"&amp;gt;
    &amp;lt;/mc:Choice&amp;gt;
    &amp;lt;mc:Fallback&amp;gt;
      &amp;lt;Label&amp;gt;
        Franken-build, beware! For test purposes only. 
        Confidential. Internal use only.
        Do not distribute.
        The official build script was not used to 
        produce this assembly.
      &amp;lt;/Label&amp;gt;
    &amp;lt;/mc:Fallback&amp;gt;
  &amp;lt;mc:AlternateContent&amp;gt;
  
  ...
  
&amp;lt/Window&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;I believe this technique is superior to other techniques I have seen 
described involving data binding and/or triggers because the resulting 
production version has no runtime overhead for the beta label. The production 
choice doesn't mention the label at all; the BAML file will not contain any 
reference to the label and no label will be created at runtime. It is equivalent 
deleting the entire alternate content block. Also, since it only uses XAML 
features, not WPF features, it is usable in non-WPF dialects.&lt;/p&gt;
&lt;p&gt;If you adopt this technique, I recommend adding the dummy namespaces to an assembly that contains only &lt;span class="code"&gt;XmlnsDefinition&lt;/span&gt; 
attributes. Since this assembly doesn't contain any code, the C# compiler will 
not include it among the references in the final assembly therefore you don't 
have to distribute it.&lt;/p&gt;
&lt;p&gt;The reason you cannot include the &lt;span class="code"&gt;XmlnsDefinition&lt;/span&gt; 
in the project itself is because the XAML is compiled before the assembly is built 
(most of the time, I will get into the details of this in a later post). The 
compiler cannot know what attributes are in the project until the project's 
assembly has been built. Since the BAML file needs to be in included in the 
assembly, it must be compiled before the assembly. This is a catch-22 so the compiler ignores
&lt;span class="code"&gt;XmlnsDefintiion&lt;/span&gt; attributes in the project assembly but 
will respect attributes in referenced assemblies (which are built before the XAML 
is compiled).&lt;/p&gt;
&lt;p&gt;In a future version of XAML we might consider adding formal support for 
conditional compilation but, for now, you can get the effect of conditional 
compilation through the use of &lt;span class="code"&gt;AlternateContent&lt;/span&gt;, even 
if it is a bit indirect.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/defa2a7d-b1e9-49eb-b8c8-438348be8d18</comments>
      <category>XAML</category>
    </item>
    <item>
      <title>XAML Part VII: Fun with markup compatibility</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/301186e3-ec80-49ec-a2b0-2052dfa32d92</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/301186e3-ec80-49ec-a2b0-2052dfa32d92</link>
      <pubDate>Fri, 13 Oct 2006 12:49:26 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;If you misspell an attribute name in an HTML document the browser will simply 
ignore it. For example, if you spell the &lt;span class="code"&gt;href&lt;/span&gt; 
attribute as &lt;span class="code"&gt;zhref&lt;/span&gt; the &lt;span class="code"&gt;&amp;lt;a&amp;gt;&lt;/span&gt; 
tag the attribute will be ignored. For example, &lt;a zhref="http://www.removingalldoubt.com"&gt;this is text is in 
such an 
&lt;span class="code"&gt;&amp;lt;a&amp;gt;&lt;/span&gt; tag.&lt;/a&gt; It is displayed like a link but it 
doesn't go anywhere because it doesn't contain an &lt;span class="code"&gt;href&lt;/span&gt; 
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 &amp;quot;Comment&amp;quot;, 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 
&lt;span class="code"&gt;Width&lt;/span&gt; property 
of a &lt;span class="code"&gt;Button&lt;/span&gt; but not lose the value it currently has 
which would happen if you simply deleted it. Consider the 
following,&lt;/p&gt;
&lt;pre&gt;&amp;lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&amp;gt; 
  &amp;lt;Canvas&amp;gt;
    &amp;lt;Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50"&amp;gt;
      Hello
    &amp;lt;/Button&amp;gt;
  &amp;lt;/Canvas&amp;gt;
&amp;lt;/Window&amp;gt;&lt;/pre&gt;
&lt;p&gt;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,&lt;/p&gt;
&lt;pre&gt;&amp;lt;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"&amp;gt;
  &amp;lt;Canvas&amp;gt;
    &amp;lt;Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50"&amp;gt;
      Hello
    &amp;lt;/Button&amp;gt;
  &amp;lt;/Canvas&amp;gt;
&amp;lt;/Window&amp;gt;&lt;/pre&gt;

&lt;p&gt;You can then comment out the &lt;span class="code"&gt;Width&lt;/span&gt; and 
&lt;span class="code"&gt;Height&lt;/span&gt; attributes,&lt;/p&gt;
&lt;pre&gt;&amp;lt;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"&amp;gt;
  &amp;lt;Canvas&amp;gt;
    &amp;lt;Button Canvas.Top="50" Canvas.Left="50" c:Width="100" c:Height="50"&amp;gt;
      Hello
    &amp;lt;/Button&amp;gt;
  &amp;lt;/Canvas&amp;gt;
&amp;lt;/Window&amp;gt;&lt;/pre&gt;

&lt;p&gt;You can even comment out the entire &lt;span class="code"&gt;Button&lt;/span&gt; with,&lt;/p&gt;
&lt;pre&gt;&amp;lt;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"&amp;gt;
  &amp;lt;Canvas&amp;gt;
    &amp;lt;c:Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50"&amp;gt;
      Hello
    &amp;lt;/c:Button&amp;gt;
  &amp;lt;/Canvas&amp;gt;
&amp;lt;/Window&amp;gt;&lt;/pre&gt;


&lt;p&gt;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
&lt;span class="code"&gt;xmlns:c&lt;/span&gt; and &lt;span class="code"&gt;mc:Ignorable&lt;/span&gt; 
declarations from &lt;span class="code"&gt;Window&lt;/span&gt;. 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.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>If you misspell an attribute name in an HTML document the browser will simply 
ignore it. For example, if you spell the <span class="code">href</span> 
attribute as <span class="code">zhref</span> the <span class="code">&lt;a&gt;</span> 
tag the attribute will be ignored. For example, <a zhref="http://www.removingalldoubt.com">this is text is in 
such an 
<span class="code">&lt;a&gt;</span> tag.</a> It is displayed like a link but it 
doesn't go anywhere because it doesn't contain an <span class="code">href</span> 
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 
<span class="code">Width</span> property 
of a <span class="code">Button</span> but not lose the value it currently has 
which would happen if you simply deleted it. Consider the 
following,</p>
        <pre>&lt;Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt; 
  &lt;Canvas&gt;
    &lt;Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50"&gt;
      Hello
    &lt;/Button&gt;
  &lt;/Canvas&gt;
&lt;/Window&gt;</pre>
        <p>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,</p>
        <pre>&lt;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"&gt;
  &lt;Canvas&gt;
    &lt;Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50"&gt;
      Hello
    &lt;/Button&gt;
  &lt;/Canvas&gt;
&lt;/Window&gt;</pre>
        <p>You can then comment out the <span class="code">Width</span> and 
<span class="code">Height</span> attributes,</p>
        <pre>&lt;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"&gt;
  &lt;Canvas&gt;
    &lt;Button Canvas.Top="50" Canvas.Left="50" c:Width="100" c:Height="50"&gt;
      Hello
    &lt;/Button&gt;
  &lt;/Canvas&gt;
&lt;/Window&gt;</pre>
        <p>You can even comment out the entire <span class="code">Button</span> with,</p>
        <pre>&lt;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"&gt;
  &lt;Canvas&gt;
    &lt;c:Button Canvas.Top="50" Canvas.Left="50" Width="100" Height="50"&gt;
      Hello
    &lt;/c:Button&gt;
  &lt;/Canvas&gt;
&lt;/Window&gt;</pre>
        <p>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
<span class="code">xmlns:c</span> and <span class="code">mc:Ignorable</span> 
declarations from <span class="code">Window</span>. 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.</p>
      </body>
      <comments>http://www.removingalldoubt.com/commentview.aspx/301186e3-ec80-49ec-a2b0-2052dfa32d92</comments>
      <category>Cider</category>
    </item>
    <item>
      <title>August CTP of Cider</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/72346c78-8c5a-4010-86c3-0ae202255ecd</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/72346c78-8c5a-4010-86c3-0ae202255ecd</link>
      <pubDate>Thu, 07 Sep 2006 17:54:48 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
Another month and another version of Cider. The August CTP is now available
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=935AABF9-D1D0-4FC9-B443-877D8EA6EAB8&amp;displaylang=en"&gt;
here&lt;/a&gt;. You can read the release notes and so forth from
&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Cider.HomePage"&gt;Channel 9 
here&lt;/a&gt;. Not only did we make substantial changes, a list of which can be found
&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Cider.AugustCTPReleaseNotes"&gt;
here&lt;/a&gt;, we also updated it to work with the new .NET Framework 3.0 RC1 
available
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&amp;displaylang=en"&gt;
here&lt;/a&gt;.&lt;p&gt;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...&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;As always, we really want your feedback so be sure to check out the 
discussion site
&lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?forumid=169&amp;siteid=1"&gt;
here&lt;/a&gt;.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/72346c78-8c5a-4010-86c3-0ae202255ecd</comments>
      <category>Cider</category>
    </item>
    <item>
      <title>June CTP of Cider</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/b1d3799e-ac1f-4409-b800-de2ef0c81ce4</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/b1d3799e-ac1f-4409-b800-de2ef0c81ce4</link>
      <pubDate>Wed, 28 Jun 2006 09:56:45 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;We &lt;a href="http://channel9.msdn.com/wiki/default.aspx/Cider.HomePage"&gt;
updated Cider&lt;/a&gt; to be compatible with the June CTP of WPF which is part of the
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=8d09697e-4868-4d8d-a4cf-9b82a2ae542d&amp;DisplayLang=en"&gt;
June CTP of .NET Framework 3.0&lt;/a&gt; (the new name for WinFX) and threw in some 
bonus bug fixes. Check out the new release
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=1A994549-94CB-4F61-903D-A8C8E453EEF4&amp;displaylang=en"&gt;
here&lt;/a&gt;. The release notes can be found
&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Cider.JuneCTPReleaseNotes"&gt;
here&lt;/a&gt; and, as always, we really want your feedback. If you have questions or 
comments about Cider let us know
&lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?forumid=169&amp;siteid=1"&gt;
here&lt;/a&gt;!&lt;/p&gt;
&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/b1d3799e-ac1f-4409-b800-de2ef0c81ce4</comments>
      <category>XAML</category>
    </item>
    <item>
      <title>May CTP of Cider</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/f17d949b-17e9-4836-8979-86b14e6d1c8a</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/f17d949b-17e9-4836-8979-86b14e6d1c8a</link>
      <pubDate>Wed, 24 May 2006 13:25:04 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;We have announced the May CTP of Cider
&lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?forumid=169&amp;siteid=1"&gt;
here&lt;/a&gt; and release notes and download instructions can be found
&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Cider.MayCTPReleaseNotes"&gt;
here&lt;/a&gt;. Some highlights include,&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;A much, much improved Grid experience&lt;/li&gt;
	&lt;li&gt;It can handle a much larger set of XAML files but there are still some
	&lt;a href="http://channel9.msdn.com/wiki/default.aspx/Cider.MayCTPXAMLLoadLimitations"&gt;
	limitations&lt;/a&gt; we are working on for a future CTP.&lt;/li&gt;
	&lt;li&gt;Delete key support!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But we removed some things as well,&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Document Outline support. &lt;/li&gt;
	&lt;li&gt;Zoom support. &lt;/li&gt;
	&lt;li&gt;Snap Lines. &lt;/li&gt;
	&lt;li&gt;Design support for StackPanel, DockPanel, and Canvas.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;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 &amp;quot;close to ship&amp;quot; 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.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/f17d949b-17e9-4836-8979-86b14e6d1c8a</comments>
      <category>XAML</category>
    </item>
    <item>
      <title>A Tour of XAML - Part VI - Forward Compatibility (continued)</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/12d47e2d-1767-4a3c-8802-3d5f0a624f66</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/12d47e2d-1767-4a3c-8802-3d5f0a624f66</link>
      <pubDate>Sat, 18 Mar 2006 17:25:10 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;Returning to the Party example we where using, lets say you want to author a 
document that has 10 kazoos when the version 2 assembly is present but replaces 
them with 4 extra balloons if we only have the version 1 assembly. This can be 
written using a markup compatibility AlternateContent block. This might look 
like,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;mc:AlternateContent&amp;gt;
            &amp;lt;mc:Choice Requires="v2"&amp;gt;
                &amp;lt;Balloon Color="Green" Shape="Dog" /&amp;gt;
                &amp;lt;v2:Favor Kind="Kazoo" Quantity="10" /&amp;gt;
            &amp;lt;/mc:Choice&amp;gt;
            &amp;lt;mc:Fallback&amp;gt;
                &amp;lt;Balloon Color="Green" /&amp;gt;
                &amp;lt;Balloon Color="Violet" /&amp;gt;
                &amp;lt;Balloon Color="Orange" /&amp;gt;
                &amp;lt;Balloon Color="Yellow" /&amp;gt;
            &amp;lt;/mc:Fallback&amp;gt;
        &amp;lt;/mc:AlternateContent&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;When the version 1 assembly is present this is interpreted as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party xmln="...assembly-v1-uri..."&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;Balloon Color="Green" /&amp;gt;
        &amp;lt;Balloon Color="Violet" /&amp;gt;
        &amp;lt;Balloon Color="Orange" /&amp;gt;
        &amp;lt;Balloon Color="Yellow" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;but in version 2 it is interpreted as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party xmlns="...assembly-v2-uri..."&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;Balloon Color="Green" Shape="Dog" /&amp;gt;
        &amp;lt;Favor Kind="Kazoo" Quantity="10" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;The content of the Choice element is used when the 
v2 namespace is available because it is mentioned in the Requires attribute. 
This corresponds to when the version 2 assembly is in use. If v2 is not 
available, the content of the Fallback element is used. AlternateContent 
supports an arbitrary list of Choice elements and the Requires can be an 
arbitrary list of prefix names. &lt;/p&gt;
&lt;p&gt;Of course exchanging balloons for kazoos is not a very compelling example. For a more practical example, let's 
assume we have following classes in version 1 of an assembly,&lt;/p&gt;
&lt;pre&gt;    [ContentProperty("Content")]
    &lt;b&gt;class&lt;/b&gt; Paragraph {
        &lt;b&gt;private&lt;/b&gt; List&amp;lt;Inline&amp;gt; _content = new List&amp;lt;Inline&amp;gt;();
        &lt;b&gt;public&lt;/b&gt; List&amp;lt;Inline&amp;gt; Content { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _content; } }
    }
    
    &lt;b&gt;abstract&lt;/b&gt; &lt;b&gt;class&lt;/b&gt; Inline { }
    
    [ContentProperty("Text")]
    &lt;b&gt;class&lt;/b&gt; Run : Inline {
        &lt;b&gt;string&lt;/b&gt; _text;
        &lt;b&gt;public&lt;/b&gt; &lt;b&gt;string&lt;/b&gt; Text { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _text; } &lt;b&gt;set&lt;/b&gt; { _text = value; } }
    }
    
    &lt;b&gt;class&lt;/b&gt; Image : Inline {
        &lt;b&gt;private&lt;/b&gt; Uri _source;
        &lt;b&gt;public&lt;/b&gt; Uri Source { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _source; } &lt;b&gt;set&lt;/b&gt; { _source = value; } }
    }&lt;/pre&gt;

&lt;p&gt;Now in the version 2 assembly we add a new class that looks like,&lt;/p&gt;
&lt;pre&gt;    &lt;b&gt;class&lt;/b&gt; Graph : Inline {
        &lt;b&gt;private&lt;/b&gt; List&amp;lt;Point&amp;gt; _points = &lt;b&gt;new&lt;/b&gt; List&amp;lt;Point&amp;gt;();
        &lt;b&gt;public&lt;/b&gt; List&amp;lt;Point&amp;gt; Points { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _points; } }
    }&lt;/pre&gt;

&lt;p&gt;Now we want to write a paragraph that uses the new Graph class when version 2 
of the assembly is present, because, for example, it scales better, but in 
version 1 we will just use a bitmap image of the graph. This might 
look like,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&amp;gt;
        &amp;lt;Run&amp;gt;The sales projects for the next quarter are&amp;lt;/Run&amp;gt;
        &amp;lt;AlternateContent&amp;gt;
            &amp;lt;mc:Choice Requires="v2"&amp;gt;
                &amp;lt;v2:Graph Data="1,2 2,3 3,5" /&amp;gt;
            &amp;lt;/mc:Choice&amp;gt;
            &amp;lt;mc:Fallback&amp;gt;
                 &amp;lt;Image Source="SalesData.jpg&amp;quot; /&amp;gt;
            &amp;lt;/mc:Fallback&amp;gt;
        &amp;lt;/mc:AlternateContent&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;

&lt;p&gt;When the version 2 assembly is present, this is interpreted as,&lt;/p&gt;

&lt;pre&gt;    &amp;lt;Paragraph xmlns="...assembly-v2-uri..."&amp;gt;
        &amp;lt;Run&amp;gt;The sales projects for the next quarter are&amp;lt;/Run&amp;gt;
        &amp;lt;Graph Data="1,2 2,3 3,5" /&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;
    
&lt;p&gt;but, when only version 1 available, it is interpreted as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph xmln="...assembly-v1-uri..."&amp;gt;
        &amp;lt;Run&amp;gt;The sales projects for the next quarter are&amp;lt;/Run&amp;gt;
        &amp;lt;Image Source="SalesData.jpg&amp;quot; /&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;
    
&lt;p&gt;using the bitmap instead of of the Graph class. This allows a document author 
to produce a file that takes advantage of a new feature, such as Graph with its 
better scaling properties, but still allows older versions to see a the graph at 
a lower fidelity.&lt;/p&gt;
    
&lt;p&gt;These classes make a better example for another feature of markup 
compatibility, the ProcessContent attribute. Let's add another class in the 
version 2 assembly,&lt;/p&gt;
&lt;pre&gt;    [ContentProperty("Content")]
    &lt;b&gt;class&lt;/b&gt; Glow : Inline {
        &lt;b&gt;private&lt;/b&gt; List&amp;lt;Inline&amp;gt; _content = new List&amp;lt;Inline&amp;gt;();
        &lt;b&gt;public&lt;/b&gt; List&amp;lt;Inline&amp;gt; Content { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _content; } }
    }&lt;/pre&gt;
    
&lt;p&gt;This class allows us to make the content to appear to glow when drawn. This 
allows us to write a document that looks like,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&amp;gt;
        &amp;lt;Run&amp;gt;The word&amp;lt;/Run&amp;gt; 
        &amp;lt;v2:Glow&amp;gt;&amp;lt;Run&amp;gt;glow&amp;lt;/Run&amp;gt;&amp;lt;/v2:Glow&amp;gt; 
        &amp;lt;Run&amp;gt;will appear to glow when it viewed with version 2.&amp;lt;/Run&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;
    
&lt;p&gt;Unfortunately, with version 1, this is interpreted as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph xmln="...assembly-v1-uri..."&amp;gt;
        &amp;lt;Run&amp;gt;The word&amp;lt;/Run&amp;gt; 
        &amp;lt;Run&amp;gt;will appear to glow when it viewed with version 2.&amp;lt;/Run&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;
&lt;p&gt;The word &amp;quot;glow&amp;quot; disappeared because, by default, when an element is ignored its 
content is ignored as well. This default can be modified by using the ProcessContent attribute. If the original document is modified to be,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph 
      mc:Ignorable="v2" 
      mc:ProcessContent="v2:Glow"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&amp;gt;
        &amp;lt;Run&amp;gt;The word&amp;lt;/Run&amp;gt; 
        &amp;lt;v2:Glow&amp;gt;&amp;lt;Run&amp;gt;glow&amp;lt;/Run&amp;gt;&amp;lt;/v2:Glow&amp;gt; 
        &amp;lt;Run&amp;gt;will appear to glow when it viewed with version 2.&amp;lt;/Run&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;
&lt;p&gt;This will tell the reader to just ignore the tags for Glow if it doesn't 
understand it but leave the content intact. This is then interpreted as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph xmln="...assembly-v1-uri..."&amp;gt;
        &amp;lt;Run&amp;gt;The word&amp;lt;/Run&amp;gt; 
        &amp;lt;Run&amp;gt;glow&amp;lt;/Run&amp;gt;
        &amp;lt;Run&amp;gt;will appear to glow when it viewed with version 2.&amp;lt;/Run&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;

&lt;p&gt;for version 1, and will be interpreted as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Paragraph xmlns:v2="...assembly-v2-uri..."&amp;gt;
        &amp;lt;Run&amp;gt;The word&amp;lt;/Run&amp;gt; 
        &amp;lt;Glow&amp;gt;&amp;lt;Run&amp;gt;glow&amp;lt;/Run&amp;gt;&amp;lt;/Glow&amp;gt; 
        &amp;lt;Run&amp;gt;will appear to glow when it viewed with version 2.&amp;lt;/Run&amp;gt;
    &amp;lt;/Paragraph&amp;gt;&lt;/pre&gt;

&lt;p&gt;when version 2 is present which is exactly what we wanted.&lt;/p&gt;
&lt;p&gt;In general, forward compatibility allows previous versions of a document 
reader to read a document intended for later versions and render the content at 
a lower fidelity. This helps immensely when deploying a newer version of an 
assembly. During initial deployment it might not be that wide spread. You can 
have your users start taking advantage of the new features immediately because 
older versions will still be able to read newer documents, at a lower fidelity, 
even when they don't have the new assembly.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>Returning to the Party example we where using, lets say you want to author a 
document that has 10 kazoos when the version 2 assembly is present but replaces 
them with 4 extra balloons if we only have the version 1 assembly. This can be 
written using a markup compatibility AlternateContent block. This might look 
like,</p>
        <pre>    &lt;Party mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;mc:AlternateContent&gt;
            &lt;mc:Choice Requires="v2"&gt;
                &lt;Balloon Color="Green" Shape="Dog" /&gt;
                &lt;v2:Favor Kind="Kazoo" Quantity="10" /&gt;
            &lt;/mc:Choice&gt;
            &lt;mc:Fallback&gt;
                &lt;Balloon Color="Green" /&gt;
                &lt;Balloon Color="Violet" /&gt;
                &lt;Balloon Color="Orange" /&gt;
                &lt;Balloon Color="Yellow" /&gt;
            &lt;/mc:Fallback&gt;
        &lt;/mc:AlternateContent&gt;
    &lt;/Party&gt;</pre>
        <p>When the version 1 assembly is present this is interpreted as,</p>
        <pre>    &lt;Party xmln="...assembly-v1-uri..."&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;Balloon Color="Green" /&gt;
        &lt;Balloon Color="Violet" /&gt;
        &lt;Balloon Color="Orange" /&gt;
        &lt;Balloon Color="Yellow" /&gt;
    &lt;/Party&gt;</pre>
        <p>but in version 2 it is interpreted as,</p>
        <pre>    &lt;Party xmlns="...assembly-v2-uri..."&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;Balloon Color="Green" Shape="Dog" /&gt;
        &lt;Favor Kind="Kazoo" Quantity="10" /&gt;
    &lt;/Party&gt;</pre>
        <p>The content of the Choice element is used when the 
v2 namespace is available because it is mentioned in the Requires attribute. 
This corresponds to when the version 2 assembly is in use. If v2 is not 
available, the content of the Fallback element is used. AlternateContent 
supports an arbitrary list of Choice elements and the Requires can be an 
arbitrary list of prefix names. </p>
        <p>Of course exchanging balloons for kazoos is not a very compelling example. For a more practical example, let's 
assume we have following classes in version 1 of an assembly,</p>
        <pre>    [ContentProperty("Content")]
    <b>class</b> Paragraph {
        <b>private</b> List&lt;Inline&gt; _content = new List&lt;Inline&gt;();
        <b>public</b> List&lt;Inline&gt; Content { <b>get</b> { <b>return</b> _content; } }
    }
    
    <b>abstract</b><b>class</b> Inline { }
    
    [ContentProperty("Text")]
    <b>class</b> Run : Inline {
        <b>string</b> _text;
        <b>public</b><b>string</b> Text { <b>get</b> { <b>return</b> _text; } <b>set</b> { _text = value; } }
    }
    
    <b>class</b> Image : Inline {
        <b>private</b> Uri _source;
        <b>public</b> Uri Source { <b>get</b> { <b>return</b> _source; } <b>set</b> { _source = value; } }
    }</pre>
        <p>Now in the version 2 assembly we add a new class that looks like,</p>
        <pre>
          <b>class</b> Graph : Inline {
        <b>private</b> List&lt;Point&gt; _points = <b>new</b> List&lt;Point&gt;();
        <b>public</b> List&lt;Point&gt; Points { <b>get</b> { <b>return</b> _points; } }
    }</pre>
        <p>Now we want to write a paragraph that uses the new Graph class when version 2 
of the assembly is present, because, for example, it scales better, but in 
version 1 we will just use a bitmap image of the graph. This might 
look like,</p>
        <pre>    &lt;Paragraph mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&gt;
        &lt;Run&gt;The sales projects for the next quarter are&lt;/Run&gt;
        &lt;AlternateContent&gt;
            &lt;mc:Choice Requires="v2"&gt;
                &lt;v2:Graph Data="1,2 2,3 3,5" /&gt;
            &lt;/mc:Choice&gt;
            &lt;mc:Fallback&gt;
                 &lt;Image Source="SalesData.jpg" /&gt;
            &lt;/mc:Fallback&gt;
        &lt;/mc:AlternateContent&gt;
    &lt;/Paragraph&gt;</pre>
        <p>When the version 2 assembly is present, this is interpreted as,</p>
        <pre>    &lt;Paragraph xmlns="...assembly-v2-uri..."&gt;
        &lt;Run&gt;The sales projects for the next quarter are&lt;/Run&gt;
        &lt;Graph Data="1,2 2,3 3,5" /&gt;
    &lt;/Paragraph&gt;</pre>
        <p>but, when only version 1 available, it is interpreted as,</p>
        <pre>    &lt;Paragraph xmln="...assembly-v1-uri..."&gt;
        &lt;Run&gt;The sales projects for the next quarter are&lt;/Run&gt;
        &lt;Image Source="SalesData.jpg" /&gt;
    &lt;/Paragraph&gt;</pre>
        <p>using the bitmap instead of of the Graph class. This allows a document author 
to produce a file that takes advantage of a new feature, such as Graph with its 
better scaling properties, but still allows older versions to see a the graph at 
a lower fidelity.</p>
        <p>These classes make a better example for another feature of markup 
compatibility, the ProcessContent attribute. Let's add another class in the 
version 2 assembly,</p>
        <pre>    [ContentProperty("Content")]
    <b>class</b> Glow : Inline {
        <b>private</b> List&lt;Inline&gt; _content = new List&lt;Inline&gt;();
        <b>public</b> List&lt;Inline&gt; Content { <b>get</b> { <b>return</b> _content; } }
    }</pre>
        <p>This class allows us to make the content to appear to glow when drawn. This 
allows us to write a document that looks like,</p>
        <pre>    &lt;Paragraph mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&gt;
        &lt;Run&gt;The word&lt;/Run&gt; 
        &lt;v2:Glow&gt;&lt;Run&gt;glow&lt;/Run&gt;&lt;/v2:Glow&gt; 
        &lt;Run&gt;will appear to glow when it viewed with version 2.&lt;/Run&gt;
    &lt;/Paragraph&gt;</pre>
        <p>Unfortunately, with version 1, this is interpreted as,</p>
        <pre>    &lt;Paragraph xmln="...assembly-v1-uri..."&gt;
        &lt;Run&gt;The word&lt;/Run&gt; 
        &lt;Run&gt;will appear to glow when it viewed with version 2.&lt;/Run&gt;
    &lt;/Paragraph&gt;</pre>
        <p>The word "glow" disappeared because, by default, when an element is ignored its 
content is ignored as well. This default can be modified by using the ProcessContent attribute. If the original document is modified to be,</p>
        <pre>    &lt;Paragraph 
      mc:Ignorable="v2" 
      mc:ProcessContent="v2:Glow"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&gt;
        &lt;Run&gt;The word&lt;/Run&gt; 
        &lt;v2:Glow&gt;&lt;Run&gt;glow&lt;/Run&gt;&lt;/v2:Glow&gt; 
        &lt;Run&gt;will appear to glow when it viewed with version 2.&lt;/Run&gt;
    &lt;/Paragraph&gt;</pre>
        <p>This will tell the reader to just ignore the tags for Glow if it doesn't 
understand it but leave the content intact. This is then interpreted as,</p>
        <pre>    &lt;Paragraph xmln="...assembly-v1-uri..."&gt;
        &lt;Run&gt;The word&lt;/Run&gt; 
        &lt;Run&gt;glow&lt;/Run&gt;
        &lt;Run&gt;will appear to glow when it viewed with version 2.&lt;/Run&gt;
    &lt;/Paragraph&gt;</pre>
        <p>for version 1, and will be interpreted as,</p>
        <pre>    &lt;Paragraph xmlns:v2="...assembly-v2-uri..."&gt;
        &lt;Run&gt;The word&lt;/Run&gt; 
        &lt;Glow&gt;&lt;Run&gt;glow&lt;/Run&gt;&lt;/Glow&gt; 
        &lt;Run&gt;will appear to glow when it viewed with version 2.&lt;/Run&gt;
    &lt;/Paragraph&gt;</pre>
        <p>when version 2 is present which is exactly what we wanted.</p>
        <p>In general, forward compatibility allows previous versions of a document 
reader to read a document intended for later versions and render the content at 
a lower fidelity. This helps immensely when deploying a newer version of an 
assembly. During initial deployment it might not be that wide spread. You can 
have your users start taking advantage of the new features immediately because 
older versions will still be able to read newer documents, at a lower fidelity, 
even when they don't have the new assembly.</p>
      </body>
      <comments>http://www.removingalldoubt.com/commentview.aspx/12d47e2d-1767-4a3c-8802-3d5f0a624f66</comments>
      <category>Programming</category>
    </item>
    <item>
      <title>A Tour of XAML V: Forward compatibility</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/25290e01-64e5-49dd-919f-374f2162542c</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/25290e01-64e5-49dd-919f-374f2162542c</link>
      <pubDate>Sun, 12 Feb 2006 18:28:43 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;As we saw last time, XAML supports backwards compatibility. XAML also 
supports forward compatibility. Forward compatibility is easiest to understand from through a set of examples. Take the balloon 
example before. Say we want to write a XAML document that says, when you have 
the version 2 assembly, I want a dog shaped balloon. If, however, you only have 
the version 1 assembly, a default shaped balloon is fine. In other words, I want 
a document that contains some version 2 specific references in it but it is OK to just ignore 
them when you have a version 1 assembly. In our example, we want to mark the Shape property some way that 
the version 1 reader will know it can ignore the property. In XAML you can use 
the markup compatibility namespace to accomplish this. You can write,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" v2:Shape="Dog" 
      xmlns="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"
      mc:Ignorable="v2" /&amp;gt;&lt;/pre&gt;
&lt;p&gt;This takes advantage of the Ignorable attribute of from the markup 
compatibility namespace. mc:Ignorable=&amp;quot;v2&amp;quot; says that any attribute or element 
from the namespace 
associated with the &amp;quot;v2&amp;quot; prefix can be ignored and you would still have a 
document that would have an acceptable meaning. If a XAML reader only has the 
version 1 assembly, it would interpreted the above document as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" xmlns="...assembly-v1-uri..."  /&amp;gt;&lt;/pre&gt;
&lt;p&gt;If the reader has the version 2 assembly, it would interpret it as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" Shape="Dog" xmlns="...assembly-v2-uri..." /&amp;gt;&lt;/pre&gt;
&lt;p&gt;mc:Ignorable can also applies to elements. To see example of this lets define a class, Party, that is 
define as,&lt;/p&gt;
&lt;pre&gt;    [ContentProperty("Balloons")]
    &lt;b&gt;public&lt;/b&gt; &lt;b&gt;class&lt;/b&gt; Party {
        List&amp;lt;Balloon&amp;gt; _balloons = &lt;b&gt;new&lt;/b&gt; List&amp;lt;Balloon&amp;gt;();
        &lt;b&gt;public&lt;/b&gt; List&amp;lt;Balloon&amp;gt; Balloons { &lt;b&gt;get&lt;/b&gt; { return _balloons; } 
    }&lt;/pre&gt;
&lt;p&gt;This allows us to define a Party instance that contains balloons. For this 
example, let's assume that Party was defined in the Version 1 assembly and is 
unmodified in the Version 2 assembly. We can then 
write a XAML document that looks like,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party xmln="...assembly-v1-uri..."&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;
&lt;p&gt;We can now also write a document that will include a third dog shaped balloon 
but only if we are using the version 2 assembly, and not include if we are still 
using version 1. It looks like,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;v2:Balloon Color="Green" Shape="Dog" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;This will be interpreted exactly as the prior document when reading it with 
version 1. With version 2, however, it would be interpreted as if it was,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party xmlns="...assembly-v2-uri..."&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;Balloon Color="Green" Shape="Dog" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;We can also add a new a new class, such as Favor, that can be used in a 
document such as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;v2:Balloon Color="Green" Shape="Dog" /&amp;gt;
        &amp;lt;v2:Favor Kind="Kazoo" Quantity="10" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;This doesn't affect the version 1 interpretation of the document, but adds 10 kazoos to 
the version 2 interpretation. If the author determines that the kazoos are 
really necessary to the interpretation of either the reference to v1 can be 
removed and the document rewritten to,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Party xmlns="...assembly-v2-uri..."&amp;gt;
        &amp;lt;Balloon Color="Red" /&amp;gt;
        &amp;lt;Balloon Color="Blue" /&amp;gt;
        &amp;lt;Balloon Color="Green" Shape="Dog" /&amp;gt;
        &amp;lt;Favor Kind="Kazoo" Quantity="10" /&amp;gt;
    &amp;lt;/Party&amp;gt;&lt;/pre&gt;

&lt;p&gt;or the the ignorable attribute can just be removed which amounts to an 
equivalent document given subsumption described in the previous entry.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>As we saw last time, XAML supports backwards compatibility. XAML also 
supports forward compatibility. Forward compatibility is easiest to understand from through a set of examples. Take the balloon 
example before. Say we want to write a XAML document that says, when you have 
the version 2 assembly, I want a dog shaped balloon. If, however, you only have 
the version 1 assembly, a default shaped balloon is fine. In other words, I want 
a document that contains some version 2 specific references in it but it is OK to just ignore 
them when you have a version 1 assembly. In our example, we want to mark the Shape property some way that 
the version 1 reader will know it can ignore the property. In XAML you can use 
the markup compatibility namespace to accomplish this. You can write,</p>
        <pre>    &lt;Balloon Color="Red" v2:Shape="Dog" 
      xmlns="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"
      mc:Ignorable="v2" /&gt;</pre>
        <p>This takes advantage of the Ignorable attribute of from the markup 
compatibility namespace. mc:Ignorable="v2" says that any attribute or element 
from the namespace 
associated with the "v2" prefix can be ignored and you would still have a 
document that would have an acceptable meaning. If a XAML reader only has the 
version 1 assembly, it would interpreted the above document as,</p>
        <pre>    &lt;Balloon Color="Red" xmlns="...assembly-v1-uri..."  /&gt;</pre>
        <p>If the reader has the version 2 assembly, it would interpret it as,</p>
        <pre>    &lt;Balloon Color="Red" Shape="Dog" xmlns="...assembly-v2-uri..." /&gt;</pre>
        <p>mc:Ignorable can also applies to elements. To see example of this lets define a class, Party, that is 
define as,</p>
        <pre>    [ContentProperty("Balloons")]
    <b>public</b><b>class</b> Party {
        List&lt;Balloon&gt; _balloons = <b>new</b> List&lt;Balloon&gt;();
        <b>public</b> List&lt;Balloon&gt; Balloons { <b>get</b> { return _balloons; } 
    }</pre>
        <p>This allows us to define a Party instance that contains balloons. For this 
example, let's assume that Party was defined in the Version 1 assembly and is 
unmodified in the Version 2 assembly. We can then 
write a XAML document that looks like,</p>
        <pre>    &lt;Party xmln="...assembly-v1-uri..."&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
    &lt;/Party&gt;</pre>
        <p>We can now also write a document that will include a third dog shaped balloon 
but only if we are using the version 2 assembly, and not include if we are still 
using version 1. It looks like,</p>
        <pre>    &lt;Party mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;v2:Balloon Color="Green" Shape="Dog" /&gt;
    &lt;/Party&gt;</pre>
        <p>This will be interpreted exactly as the prior document when reading it with 
version 1. With version 2, however, it would be interpreted as if it was,</p>
        <pre>    &lt;Party xmlns="...assembly-v2-uri..."&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;Balloon Color="Green" Shape="Dog" /&gt;
    &lt;/Party&gt;</pre>
        <p>We can also add a new a new class, such as Favor, that can be used in a 
document such as,</p>
        <pre>    &lt;Party mc:Ignorable="v2"
      xmln="...assembly-v1-uri..."
      xmlns:v2="...assembly-v2-uri..."
      xmlns:mc="http://schemas.micrsoft.com/winfx/2006/markup-compatibility"&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;v2:Balloon Color="Green" Shape="Dog" /&gt;
        &lt;v2:Favor Kind="Kazoo" Quantity="10" /&gt;
    &lt;/Party&gt;</pre>
        <p>This doesn't affect the version 1 interpretation of the document, but adds 10 kazoos to 
the version 2 interpretation. If the author determines that the kazoos are 
really necessary to the interpretation of either the reference to v1 can be 
removed and the document rewritten to,</p>
        <pre>    &lt;Party xmlns="...assembly-v2-uri..."&gt;
        &lt;Balloon Color="Red" /&gt;
        &lt;Balloon Color="Blue" /&gt;
        &lt;Balloon Color="Green" Shape="Dog" /&gt;
        &lt;Favor Kind="Kazoo" Quantity="10" /&gt;
    &lt;/Party&gt;</pre>
        <p>or the the ignorable attribute can just be removed which amounts to an 
equivalent document given subsumption described in the previous entry.</p>
      </body>
      <comments>http://www.removingalldoubt.com/commentview.aspx/25290e01-64e5-49dd-919f-374f2162542c</comments>
      <category>Programming</category>
    </item>
    <item>
      <title>Tour of XAML IV: Backward compatibility</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/70564b92-7b34-424c-97e5-916c7f661eb8</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/70564b92-7b34-424c-97e5-916c7f661eb8</link>
      <pubDate>Thu, 02 Feb 2006 13:50:35 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;XAML has support for both forward and backward compatibility of XAML 
documents. To understand backwards compatibility in a more formal sense, think 
of a XAML reader combined with some set of assemblies as the predicate that 
defines a set. If the reader with the given set of assemblies accepts a XAML 
document 
without error it is part of the set. If it rejects a document, it is not part of 
the set. You can think of the XAML reader and assemblies as defining a set, &lt;i&gt;{r(s,x)|x}&lt;/i&gt; where &lt;i&gt;x&lt;/i&gt; 
is the XAML file and &lt;i&gt;r(s,x)&lt;/i&gt; is the XAML reader and &lt;i&gt;s&lt;/i&gt; is a set of 
assemblies. You can then describe the relationship between&amp;nbsp; two sets of 
assemblies with respect to XAML. The assemblies imply set schemas that the XAML 
reader uses to interpret the XAML document. The schema implied by the WPF 
assemblies states there is a Button element and a DockPanel element and the 
Button element can be included in a DockPanel as one of it children, for 
example. The a set of implied schemas&amp;nbsp; &lt;i&gt;s&lt;sub&gt;2&lt;/sub&gt;&lt;/i&gt; is backwards compatible 
with &lt;i&gt;s&lt;sub&gt;1&lt;/sub&gt;&lt;/i&gt; if &lt;i&gt;{r(s&lt;sub&gt;1&lt;/sub&gt;, x)|x} &amp;#x2229; {r(s&lt;sub&gt;2&lt;/sub&gt;,
x)|x} = {r(s&lt;sub&gt;1&lt;/sub&gt;, x)|x}&lt;/i&gt; or, in other words, &lt;i&gt;s&lt;sub&gt;2&lt;/sub&gt;&lt;/i&gt; is 
backwards compatible with &lt;i&gt;s&lt;sub&gt;1&lt;/sub&gt;&lt;/i&gt; if the reader will accept same XAML documents 
with &lt;i&gt;s&lt;/i&gt;&lt;sub&gt;&lt;i&gt;2&lt;/i&gt;&lt;/sub&gt; as it accepts with 
&lt;i&gt;s&lt;sub&gt;1&lt;/sub&gt;&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;XAML really doesn't have to do much to claim it supports 
backwards compatibility because backwards compatibility is really a relationship 
between two sets of XAML schemas (and the implying assemblies) than it is between XAML documents. XAML, 
however, simplifies establishing this relationship by allowing one schema to declare it subsumes another 
schema. That means that, 
given both &lt;i&gt;s&lt;sub&gt;1&lt;/sub&gt;&lt;/i&gt; and &lt;i&gt;s&lt;sub&gt;2&lt;/sub&gt;&lt;/i&gt;, XAML allows &lt;i&gt;s&lt;sub&gt;2&lt;/sub&gt;&lt;/i&gt; to declare that any reference elements of 
&lt;i&gt;s&lt;sub&gt;1&lt;/sub&gt;&lt;/i&gt; should be considered a reference to elements of &lt;i&gt;s&lt;sub&gt;2&lt;/sub&gt;&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;To get more concrete, suppose you had an assembly that declared a single type,&lt;/p&gt;
&lt;pre&gt;   &lt;b&gt; public&lt;/b&gt; &lt;b&gt;class&lt;/b&gt; Balloon {
        Color _color;
        
        &lt;b&gt;public&lt;/b&gt; Color Color { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _color; } &lt;b&gt;set&lt;/b&gt; { _color = value; } }
    }&lt;/pre&gt;
&lt;p&gt;A XAML reader will infer a schema that would allow you to write a XAML 
document like,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" xmlns="...assembly-v1-uri..." /&amp;gt&lt;/pre&gt;
&lt;p&gt;Now, lets say, in version 2 of the assembly you want to add a shape to the balloon 
class to support different balloon shapes. In the version 2 assembly you can modify 
the class to,&lt;/p&gt;
&lt;pre&gt;    &lt;b&gt;public&lt;/b&gt; &lt;b&gt;class&lt;/b&gt; Balloon {
        Color _color;
        Shape _shape;
        
        &lt;b&gt;public&lt;/b&gt; Color Color { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _color; } &lt;b&gt;set&lt;/b&gt; { _color = value; } }
        &lt;b&gt;public&lt;/b&gt; Shape Shape { &lt;b&gt;get&lt;/b&gt; { &lt;b&gt;return&lt;/b&gt; _shape; } &lt;b&gt;set&lt;/b&gt; { _shape = value; } }
    }&lt;/pre&gt;
&lt;p&gt;Now we can write a XAML document that refers to the new assembly by writing,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" Shape="Dog" xmlns="...assembly-v2-uri..."/&amp;gt&lt;/pre&gt;

&lt;p&gt;We, however, still want to read all XAML documents that refer to the previous 
assembly as well using the new assembly. We can do this by declaring, in the new 
assembly, that this assembly is compatible with the old assembly with a 
XmlnsCompatibleWith(&amp;quot;...assembly-v2-uri...&amp;quot;,&amp;quot;...assembly-v1-uri...&amp;quot;) attribute. 
When the XAML reader sees that attribute, it will silently interpret all references to &amp;quot;...assembly-v1-uri...&amp;quot; as if they where referring 
to &amp;quot;...assembly-v2-uri...&amp;quot;. A XAML reader, presented with the version 2 
assembly, will treat,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" xmlns="...assembly-v1-uri..." /&amp;gt&lt;/pre&gt;
&lt;p&gt;exactly as if it was written as,&lt;/p&gt;
&lt;pre&gt;    &amp;lt;Balloon Color="Red" xmlns="...assembly-v2-uri..." /&amp;gt&lt;/pre&gt;
&lt;p&gt;This allows all XAML documents referring to version 1 assembly to be readable 
when you only have version 2 of the assembly. In fact, assuming you follow CLR 
guidelines for evolving an assembly, any XAML file that was legal using the 
version 1 assembly will be legal using the version 2 assembly.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/70564b92-7b34-424c-97e5-916c7f661eb8</comments>
      <category>Programming</category>
    </item>
    <item>
      <title>A Tour of XAML - Part III - Type converters</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/504e93e0-6edb-46bc-922c-8d919a04a830</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/504e93e0-6edb-46bc-922c-8d919a04a830</link>
      <pubDate>Sun, 16 Oct 2005 16:38:11 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;Fundamentally XAML is an object initialization language. It creates object 
and sets values to properties. XAML, however, is not limit to creating reference types. You can also create instances of any type 
that has an associated type converter. For example, XAML can create an instance of a brush 
with the following code,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Brush&amp;gt;Red&amp;lt;/Brush&amp;gt;&lt;/pre&gt;
&lt;p&gt;which creates a red solid color brush by calling the type converter 
associated with Brush. This means that,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button&amp;gt;
    &amp;lt;Button.Background&amp;gt;
      &amp;lt;Brush&amp;gt;Red&amp;lt;/Brush&amp;gt;
    &amp;lt;Button.Background&amp;gt;
  &amp;lt;/Button&amp;gt;&lt;/pre&gt;
&lt;p&gt;is equivilent to,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button Background=&amp;quot;Red&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;p&gt;XAML can be used to create value types, such as an integer, through its type 
converter as in, &lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;s:Int32&amp;gt;27&amp;lt;/s:Int32&amp;gt;&lt;/pre&gt;
&lt;p&gt;or a string,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;s:String&amp;gt;It is the time for all good men...&amp;lt;/s:String&amp;gt;&lt;/pre&gt;
&lt;p&gt;by using string's type converter. Note that XAML always refers to the CLR 
name for the type, not a language specific name such as &amp;quot;int&amp;quot; in C# or &amp;quot;Integer&amp;quot; 
in Pascal. Both of these types refer to the System.Int32 class in the CLR and 
XAML uses the CLR name, Int32. Note also that neither the XAML nor the WPF (Avalon) namespaces refer to the System 
namespace in mscorlib.dll where these types live. This mean that somewhere in the document 
you need to declare the prefix. This might look something like:&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;?Mapping ClrNamespace=&amp;quot;System&amp;quot; XmlNamespace=&amp;quot;System&amp;quot; 
  Assembly=&amp;quot;mscorlib&amp;quot;?&amp;gt;
  &amp;lt;Window
    xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;
    xmlns:s="System"&amp;gt;
      &amp;lt;Button&amp;gt;
        &amp;lt;s:String&amp;gt;It is the time for all good men...&amp;lt;/s:String&amp;gt;
      &amp;lt;/Button&amp;gt;
  &amp;lt;/Window&amp;gt;&lt;/pre&gt;
  
&lt;p&gt;Of course, for string, it is easier to write it,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Window xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;Button&amp;gt;It is the time for all good men...&amp;lt;/Button&amp;gt;
  &amp;lt;/Window&amp;gt;&lt;/pre&gt;
&lt;p&gt;but the string for is useful when you want multiple strings in a collection, say, for example, as the content of a list box,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;?Mapping ClrNamespace=&amp;quot;System&amp;quot; XmlNamespace=&amp;quot;System&amp;quot; 
  Assembly=&amp;quot;mscorlib&amp;quot;?&amp;gt;
  &amp;lt;Window
    xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;
    xmlns:s="System"&amp;gt;
      &amp;lt;ListBox&amp;gt;
        &amp;lt;s:String&amp;gt;It is the time for all good men...&amp;lt;/s:String&amp;gt;
        &amp;lt;s:String&amp;gt;to come to the aid of their country.&amp;lt;/s:String&amp;gt;
      &amp;lt;/ListBox&amp;gt;
  &amp;lt;/Window&amp;gt;&lt;/pre&gt;
&lt;p&gt;Note that if this had been written,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Window xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;ListBox&amp;gt;
      It is the time for all good men...
      to come to the aid of their country.
    &amp;lt;/ListBox&amp;gt;
  &amp;lt;/Window&amp;gt;&lt;/pre&gt;
&lt;/body&gt;
&lt;p&gt;the list box would only contain one string, not two. This is because all 
continuous text content is considered one string and not two. If you load this 
in WPF you will also notice that the string get treated as &amp;quot;It is time for all 
good men... to come to the aid of their country&amp;quot; where the spaces and line 
breaks have been collapsed. I will discuss the rules for whitespace 
normalization (collapsing) in a subsequent post. For now, if you are familiar 
with HTML, what XAML does shouldn't come as any surprise.&lt;/p&gt;&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/504e93e0-6edb-46bc-922c-8d919a04a830</comments>
      <category>Programming</category>
    </item>
    <item>
      <title>A Tour of XAML - Part II: Property Elements?</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/aad29f7c-e615-430d-8015-f19eaceb051e</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/aad29f7c-e615-430d-8015-f19eaceb051e</link>
      <pubDate>Wed, 28 Sep 2005 20:36:44 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;XAML provides two ways to set a property, either through a &lt;i&gt;Property 
Attribute&lt;/i&gt; or through a &lt;i&gt;Property Element&lt;/i&gt;. We covered &lt;i&gt;Property 
Attribute&lt;/i&gt;s last time, this time we will focus on the &lt;i&gt;Property Element&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;A &lt;i&gt;Property Element&lt;/i&gt; is an element that, instead of creating an object 
instance, set the value of a property. The following is equivalent to the 
example given in Part I but uses &lt;i&gt;Property Element&lt;/i&gt;s instead of &lt;i&gt;Property 
Attribute&lt;/i&gt;s.&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;Button.Content&amp;gt;
      Hello, World!
    &amp;lt;/Button.Content&amp;gt;
  &amp;lt;/Button&amp;gt;&lt;/pre&gt;
&lt;p&gt;The loader distinguishes a &lt;i&gt;Object Element&lt;/i&gt; from a &lt;i&gt;Property Element&lt;/i&gt; 
by the presents of the '.' in the name. The first part of the name is a 
reference to a type and the second part, after the dot, refers to the property 
name (we will discuss exactly why this is when we discuss &lt;i&gt;Attached Properties&lt;/i&gt;). Here we use Button in both &lt;i&gt;Property Element&lt;/i&gt;s. &lt;i&gt;Property Element&lt;/i&gt;s 
are necessary when the value of the property cannot be expressed as a string. 
For example, you can use a &lt;i&gt;Property Element&lt;/i&gt; to set the content of a Button 
to be another Button (not sure why you would want that, but suspend disbelieve for 
a second) as in,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;Button.Content&amp;gt;
      &amp;lt;Button Content=&amp;quot;Hello, World!&amp;quot; /&amp;gt;
    &amp;lt;/Button.Content&amp;gt;
  &amp;lt;/Button&amp;gt;&lt;/pre&gt;
&lt;p&gt;This can be written more explicitly as,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;Button.Content&amp;gt;
      &amp;lt;Button&amp;gt;
        &amp;lt;Button.Content&amp;gt;
          Hello, World!
        &amp;lt;/Button.Content&amp;gt;
      &amp;lt;/Button&amp;gt;
    &amp;lt;/Button.Content&amp;gt;
  &amp;lt;/Button&amp;gt;&lt;/pre&gt;
&lt;p&gt;As you can see, using &lt;i&gt;Property Element&lt;/i&gt;s can become a bit repetitive. 
To mitigate this, one of the properties of a class can be designated as 
the &lt;i&gt;Content Property&lt;/i&gt; which tells the load to assign direct content of the element to 
that property. In the case of Button (and all ContentControls) 
the &lt;i&gt;Content Property&lt;/i&gt; is, oddly enough, set to the property named 
Content. This allows us to write something like,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    Hello, World!
  &amp;lt;/Button&amp;gt;&lt;/pre&gt;
&lt;p&gt;for the first example above, and,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;Button&amp;gt;Hello, World!&amp;lt;/Button&amp;gt;
  &amp;lt;/Button&amp;gt;&lt;/pre&gt;
&lt;p&gt;for the second. Most Avalon classes have a &lt;i&gt;Content Property&lt;/i&gt; defined. 
For Panel's, such as DockPanel, Grid, and Canvas, their &lt;i&gt;Content Property&lt;/i&gt; 
is set to their Children collection. Any direct content of a Panel is assumed to 
be content intended for the Children property. This means the following,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;StackPanel xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;Button&amp;gt;OK&amp;lt;/Button&amp;gt;
    &amp;lt;Button&amp;gt;Cancel&amp;lt;/Button&amp;gt;
  &amp;lt;/StackPanel&amp;gt;&lt;/pre&gt;
&lt;p&gt;is an abbreviated version of,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;StackPanel xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;&amp;gt;
    &amp;lt;StackPanel.Children&amp;gt;
      &amp;lt;Button&amp;gt;
        &amp;lt;Button.Content&amp;gt;
          OK
        &amp;lt;/Button.Content&amp;gt;
      &amp;lt;/Button&amp;gt;
      &amp;lt;Button&amp;gt;
        &amp;lt;Button.Content&amp;gt;
          Cancel
        &amp;lt;/Button.Content&amp;gt;
      &amp;lt;/Button&amp;gt;
    &amp;lt;/StackPanel.Children&amp;gt;
  &amp;lt;/StackPanel&amp;gt;&lt;/pre&gt;
&lt;p&gt;Now, with &lt;i&gt;Property Element&lt;/i&gt;s and &lt;i&gt;Content Property Attribute&lt;/i&gt;s and&lt;i&gt; 
Object Element&lt;/i&gt; and &lt;i&gt;Property Attribute&lt;/i&gt; from Part I, we have covered 
the fundamentals of XAML. &lt;/p&gt;
&lt;/body&gt;
                </description>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>XAML provides two ways to set a property, either through a <i>Property 
Attribute</i> or through a <i>Property Element</i>. We covered <i>Property 
Attribute</i>s last time, this time we will focus on the <i>Property Element</i>.</p>
        <p>A <i>Property Element</i> is an element that, instead of creating an object 
instance, set the value of a property. The following is equivalent to the 
example given in Part I but uses <i>Property Element</i>s instead of <i>Property 
Attribute</i>s.</p>
        <pre class="code">  &lt;Button xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    &lt;Button.Content&gt;
      Hello, World!
    &lt;/Button.Content&gt;
  &lt;/Button&gt;</pre>
        <p>The loader distinguishes a <i>Object Element</i> from a <i>Property Element</i> 
by the presents of the '.' in the name. The first part of the name is a 
reference to a type and the second part, after the dot, refers to the property 
name (we will discuss exactly why this is when we discuss <i>Attached Properties</i>). Here we use Button in both <i>Property Element</i>s. <i>Property Element</i>s 
are necessary when the value of the property cannot be expressed as a string. 
For example, you can use a <i>Property Element</i> to set the content of a Button 
to be another Button (not sure why you would want that, but suspend disbelieve for 
a second) as in,</p>
        <pre class="code">  &lt;Button xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    &lt;Button.Content&gt;
      &lt;Button Content="Hello, World!" /&gt;
    &lt;/Button.Content&gt;
  &lt;/Button&gt;</pre>
        <p>This can be written more explicitly as,</p>
        <pre class="code">  &lt;Button xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    &lt;Button.Content&gt;
      &lt;Button&gt;
        &lt;Button.Content&gt;
          Hello, World!
        &lt;/Button.Content&gt;
      &lt;/Button&gt;
    &lt;/Button.Content&gt;
  &lt;/Button&gt;</pre>
        <p>As you can see, using <i>Property Element</i>s can become a bit repetitive. 
To mitigate this, one of the properties of a class can be designated as 
the <i>Content Property</i> which tells the load to assign direct content of the element to 
that property. In the case of Button (and all ContentControls) 
the <i>Content Property</i> is, oddly enough, set to the property named 
Content. This allows us to write something like,</p>
        <pre class="code">  &lt;Button xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    Hello, World!
  &lt;/Button&gt;</pre>
        <p>for the first example above, and,</p>
        <pre class="code">  &lt;Button xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    &lt;Button&gt;Hello, World!&lt;/Button&gt;
  &lt;/Button&gt;</pre>
        <p>for the second. Most Avalon classes have a <i>Content Property</i> defined. 
For Panel's, such as DockPanel, Grid, and Canvas, their <i>Content Property</i> 
is set to their Children collection. Any direct content of a Panel is assumed to 
be content intended for the Children property. This means the following,</p>
        <pre class="code">  &lt;StackPanel xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    &lt;Button&gt;OK&lt;/Button&gt;
    &lt;Button&gt;Cancel&lt;/Button&gt;
  &lt;/StackPanel&gt;</pre>
        <p>is an abbreviated version of,</p>
        <pre class="code">  &lt;StackPanel xmlns="http://schemas.microsoft.com/winfx/avalon/2005"&gt;
    &lt;StackPanel.Children&gt;
      &lt;Button&gt;
        &lt;Button.Content&gt;
          OK
        &lt;/Button.Content&gt;
      &lt;/Button&gt;
      &lt;Button&gt;
        &lt;Button.Content&gt;
          Cancel
        &lt;/Button.Content&gt;
      &lt;/Button&gt;
    &lt;/StackPanel.Children&gt;
  &lt;/StackPanel&gt;</pre>
        <p>Now, with <i>Property Element</i>s and <i>Content Property Attribute</i>s and<i> 
Object Element</i> and <i>Property Attribute</i> from Part I, we have covered 
the fundamentals of XAML. </p>
      </body>
      <comments>http://www.removingalldoubt.com/commentview.aspx/aad29f7c-e615-430d-8015-f19eaceb051e</comments>
      <category>Programming</category>
    </item>
    <item>
      <title>A Tour of XAML - Part I: What is XAML?</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/e19e14e5-5c03-4385-90a7-d18c4756bd8d</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/e19e14e5-5c03-4385-90a7-d18c4756bd8d</link>
      <pubDate>Sat, 24 Sep 2005 15:25:33 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
Today I begin a tour of XAML. As &lt;a href="http://www.simplegeek.com"&gt;Chris&lt;/a&gt; said, I have been part of 
development of XAML. I came fairly late to the game, however, more closely to the end of 
the Avalon development cycle than at the beginning, and XAML was already fairly 
well defined when I arrived. I did work to push some changes into the language, primarily 
driving consistency and regularity in the language as well as put developing 
features that support versioning and extensibility. We will cover some of those 
things in our tour, but lets start at the beginning.&lt;/p&gt;
&lt;p&gt;The first question we will cover in our tour is what is XAML anyway? Simply, 
XAML is an XML based object initialization language. Its job in life is to 
create a tree of objects. For example, consider the following XAML file,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button Content=&amp;quot;Hello, world!&amp;quot; 
    xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;p&gt;  This creates an instance of &lt;span class="code"&gt;System.Windows.Controls.Button&lt;/span&gt; and
sets the &lt;span class="code"&gt;Content&lt;/span&gt; property to the sting value
&lt;span class="code"&gt;&amp;quot;Hello, world!&amp;quot;&lt;/span&gt;. The reason &lt;span class="code"&gt;System.Windows.Button&lt;/span&gt; 
is selected and not, say &lt;span class="code"&gt;System.Windows.Forms.Button&lt;/span&gt;,
is because of the &lt;span class="code"&gt;xmlns&lt;/span&gt; declaration in the
&lt;span class="code"&gt;Button&lt;/span&gt; tag. The magic behind the URI &amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot; 
is hidden in the Avalon assemblies themselves. They contain an assembly 
attribute that looks like,&lt;/p&gt;
&lt;pre class="code"&gt;  [assembly: XmlnDefinition(
	&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot;,
	&amp;quot;System.Windows.Controls&amp;quot;)]&lt;/pre&gt;

&lt;p&gt;It actually has several more definitions like this to associate several other CLR 
namespaces with the Avalon XML namespace, but this is the one used above. Because 
&lt;span class="code"&gt;PresentationFramework.dll&lt;/span&gt; is in the GAC or referenced 
by the project if the XAML is compiled into assembly, the Avalon
loader will find the &lt;span class="code"&gt;XmlnsDefinition&lt;/span&gt; in the assembly
and it is able to determine that it is Avalon's button we want to create.&lt;/p&gt;
&lt;p&gt;Now lets take a look at the phrase 
&lt;span class="code"&gt;Content=&amp;quot;Hello, world!&amp;quot;&lt;/span&gt;. This causes the 
loader to look up the property called &lt;span class="code"&gt;Content&lt;/span&gt; and 
sets its value. The &lt;span class="code"&gt;Content&lt;/span&gt; property is introduced in 
&lt;span class="code"&gt;Button&lt;/span&gt;'s &lt;span class="code"&gt;ContentControl&lt;/span&gt; base class and is of type 
&lt;span class="code"&gt;System.Object&lt;/span&gt;. Since there is no applicable type 
converter for &lt;span class="code"&gt;System.Object&lt;/span&gt;, the loader uses the default type of an 
attribute, string, and 
calls the setter method for &lt;span class="code"&gt;Content&lt;/span&gt;. 
Things are slightly more complicated than this, but this should give you the 
basic idea. This gives us an instance of the 
&lt;span class="code"&gt;System.Windows.Controls.Button&lt;/span&gt;
class with its &lt;span class="code"&gt;Content&lt;/span&gt; property set to the value 
&lt;span class="code"&gt;&amp;quot;Hello, world!&amp;quot;&lt;/span&gt;, which is, hopefully, what 
we wanted.&lt;/p&gt;
&lt;p&gt;If we change the XAML to,&lt;/p&gt;
&lt;pre class="code"&gt;  &amp;lt;Button Content=&amp;quot;Hello, world!&amp;quot; IsDefault=&amp;quot;True&amp;quot;
    xmlns=&amp;quot;http://schemas.microsoft.com/winfx/avalon/2005&amp;quot; /&amp;gt;&lt;/pre&gt;
&lt;p&gt;adding the phrase &lt;span class="code"&gt;IsDefault=&amp;quot;True&amp;quot;&lt;/span&gt; which causes 
the loader to find the &lt;span class="code"&gt;IsDefault&lt;/span&gt; property introduced on 
the &lt;span class="code"&gt;Button&lt;/span&gt; class itself. The &lt;span class="code"&gt;IsDefault&lt;/span&gt;
property is of type &lt;span class="code"&gt;System.Boolean&lt;/span&gt; which has a type converter, 
&lt;span class="code"&gt;System.ComponentModel.BooleanConverter&lt;/span&gt;, associated with it. 
The loader will pass the string, &lt;span class="code"&gt;&amp;quot;True&amp;quot;&lt;/span&gt;, to the type
converter associated with the property (or, as in this case, the property's type) prior to setting the property's 
value; after which we will have an instance of the 
&lt;span class="code"&gt;System.Windows.Controls.Button&lt;/span&gt;
class with its &lt;span class="code"&gt;Content&lt;/span&gt; property set to the value 
&lt;span class="code"&gt;&amp;quot;Hello, world!&amp;quot;&lt;/span&gt;, and its &lt;span class="code"&gt;IsDefault&lt;/span&gt; 
property set to &lt;span class="code"&gt;True&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;This time we covered an &lt;i&gt;Object Element&lt;/i&gt;, an XML element used to create 
an object, and we used a &lt;i&gt;Property Attribute&lt;/i&gt;, an XML element used to set 
the value of an object instance's property. Next time we will get use a &lt;i&gt;
Property Element&lt;/i&gt; and take advantage of the &lt;i&gt;Content Property Attribute&lt;/i&gt;.&lt;/p&gt;
&lt;/body&gt;
                </description>
      <comments>http://www.removingalldoubt.com/commentview.aspx/e19e14e5-5c03-4385-90a7-d18c4756bd8d</comments>
      <category>Programming</category>
    </item>
    <item>
      <title>Cider is Announced</title>
      <guid>http://www.removingalldoubt.com/permalink.aspx/7c401e08-3ec1-4e8a-8a87-56f526192a0b</guid>
      <link>http://www.removingalldoubt.com/permalink.aspx/7c401e08-3ec1-4e8a-8a87-56f526192a0b</link>
      <pubDate>Sun, 18 Sep 2005 23:07:12 GMT</pubDate>
      <description>&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;Cider is now announced! In case you missed it at the PDC, Cider is the code 
name for the Visual Studio Designer for WPF (&lt;a href="http://www.simplegeek.com/PermaLink.aspx/848ef1d4-f694-43ee-92f7-047478b6b894"&gt;pronounced 
Avalon&lt;/a&gt; according to Chris) that will be delivered in Orcas. We also 
announced the Expression product line that includes a different designer called
&lt;a href="http://www.eweek.com/category2/0,1874,1361732,00.asp"&gt;Sparkle&lt;/a&gt;. 
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.&lt;/p&gt;
&lt;p&gt;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. &lt;/p&gt;
&lt;p&gt;I will be more forthcoming in the months ahead and try to keep you up-to-date 
with our progress.&lt;/p&gt;
&lt;p&gt;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).&lt;/p&gt;
&lt;/body&gt;
                </description>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>Cider is now announced! In case you missed it at the PDC, Cider is the code 
name for the Visual Studio Designer for WPF (<a href="http://www.simplegeek.com/PermaLink.aspx/848ef1d4-f694-43ee-92f7-047478b6b894">pronounced 
Avalon</a> according to Chris) that will be delivered in Orcas. We also 
announced the Expression product line that includes a different designer called
<a href="http://www.eweek.com/category2/0,1874,1361732,00.asp">Sparkle</a>. 
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.</p>
        <p>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. </p>
        <p>I will be more forthcoming in the months ahead and try to keep you up-to-date 
with our progress.</p>
        <p>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).</p>
      </body>
      <comments>http://www.removingalldoubt.com/commentview.aspx/7c401e08-3ec1-4e8a-8a87-56f526192a0b</comments>
      <category>PDC05</category>
    </item>
  </channel>
</rss>