<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Michael Shim &#187; XAML Toolkit</title>
	<atom:link href="http://michaelshim.com/blog/tag/xaml-toolkit/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelshim.com/blog</link>
	<description>XAML, WPF &#38; Silverlight</description>
	<lastBuildDate>Thu, 18 Mar 2010 21:59:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>XAML Toolkit CTP &#8211; November 2009 is now live!</title>
		<link>http://michaelshim.com/blog/2009/11/23/xaml-toolkit-ctp-november-2009-is-now-live/</link>
		<comments>http://michaelshim.com/blog/2009/11/23/xaml-toolkit-ctp-november-2009-is-now-live/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 01:35:17 +0000</pubDate>
		<dc:creator>Michael Shim</dc:creator>
				<category><![CDATA[XAML]]></category>
		<category><![CDATA[PDC]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML Toolkit]]></category>

		<guid isPermaLink="false">http://michaelshim.com/blog/2009/11/23/xaml-toolkit-ctp-november-2009-is-now-live/</guid>
		<description><![CDATA[The XAML Toolkit CTP is now live at the code gallery website.&#160; 
Here’s a guide on how to run the rules in FxCop.
]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/">XAML Toolkit CTP</a> is now live at the code gallery <a href="http://code.msdn.microsoft.com/XAML">website</a>.&#160; </p>
<p><a href="http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/">Here’s</a> a guide on how to run the rules in FxCop.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelshim.com/blog/2009/11/23/xaml-toolkit-ctp-november-2009-is-now-live/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running FxCop rules against Silverlight or WPF XAML</title>
		<link>http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/</link>
		<comments>http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 21:37:32 +0000</pubDate>
		<dc:creator>Michael Shim</dc:creator>
				<category><![CDATA[XAML]]></category>
		<category><![CDATA[FxCop]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Static Analysis]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[XAML Toolkit]]></category>

		<guid isPermaLink="false">http://michaelshim.com/blog/?p=29</guid>
		<description><![CDATA[Read the README that’s included as part of the XAML Toolkit CTP.
The big thing to note is that FxCop 10 Beta 2 does not currently support Silverlight.  You’ll have to use FxCop 1.36 and force it to run in .NET 4 to get things to work for Silverlight.  If you’re running WPF, FxCop 10 should [...]]]></description>
			<content:encoded><![CDATA[<p>Read the README that’s included as part of the <a href="http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/">XAML Toolkit CTP</a>.</p>
<p>The big thing to note is that FxCop 10 Beta 2 does not currently support Silverlight.  You’ll have to use FxCop 1.36 and force it to run in .NET 4 to get things to work for Silverlight.  If you’re running WPF, FxCop 10 should be fine.  (FxCop 10 RC &amp; RTM wills support Silverlight)</p>
<p>After running FxCop, add the XAML Rule</p>
<p><a href="http://michaelshim.com/blog/wp-content/uploads/2009/11/AddRule.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="AddRule" src="http://michaelshim.com/blog/wp-content/uploads/2009/11/AddRule_thumb.png" border="0" alt="AddRule" width="641" height="484" /></a></p>
<p>Go to the folder where you installed the XAML Toolkit (C:\Program Files\Microsoft XAML Toolkit\) and add Microsoft.Xaml.Tools.FxCop.dll</p>
<p><a href="http://michaelshim.com/blog/wp-content/uploads/2009/11/XamlToolsFxCopdll.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="XamlToolsFxCopdll" src="http://michaelshim.com/blog/wp-content/uploads/2009/11/XamlToolsFxCopdll_thumb.png" border="0" alt="XamlToolsFxCopdll" width="604" height="484" /></a></p>
<p>You should see all the XAML rules added in the Rules section:</p>
<p><a href="http://michaelshim.com/blog/wp-content/uploads/2009/11/XamlRules.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="XamlRules" src="http://michaelshim.com/blog/wp-content/uploads/2009/11/XamlRules_thumb.png" border="0" alt="XamlRules" width="641" height="484" /></a></p>
<p>Add your Silverlight/WPF assembly and hit F5 (or Analyze).  You may get a popup about finding System.Windows.dll.  Have it point to C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0</p>
<p>WPF users can point to PresentationFramework/PresentationCore/WindowsBase in C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0</p>
<p>You may also need to point FxCop towards System.Windows.Controls.dll which can be found in: C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client</p>
<p><a href="http://michaelshim.com/blog/wp-content/uploads/2009/11/SystemWindows.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SystemWindows" src="http://michaelshim.com/blog/wp-content/uploads/2009/11/SystemWindows_thumb.png" border="0" alt="SystemWindows" width="538" height="287" /></a></p>
<p>If everything goes smoothly you should see the rules run:</p>
<p><a href="http://michaelshim.com/blog/wp-content/uploads/2009/11/FinalRules.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="FinalRules" src="http://michaelshim.com/blog/wp-content/uploads/2009/11/FinalRules_thumb.png" border="0" alt="FinalRules" width="641" height="484" /></a></p>
<p>You should be able to do similar things for adding your own custom rules to FxCop as well.</p>
<p> </p>
<p> </p>
<p>One of the most common requests I had at PDC was to be able check if your WPF XAML was Silverlight friendly and vice versa.  Over the next few weeks, I’ll try working on some simple rules to validate WPF/Silverlight compatibility and whether you can use the XAML between the two platforms.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelshim.com/blog/2009/11/23/running-fxcop-rules-against-silverlight-xaml/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>XAML Toolkit CTP</title>
		<link>http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/</link>
		<comments>http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 22:00:37 +0000</pubDate>
		<dc:creator>Michael Shim</dc:creator>
				<category><![CDATA[XAML]]></category>
		<category><![CDATA[PDC]]></category>
		<category><![CDATA[XAML Toolkit]]></category>
		<category><![CDATA[XamlDom]]></category>

		<guid isPermaLink="false">http://michaelshim.com/blog/?p=11</guid>
		<description><![CDATA[At PDC, we&#8217;re announcing a CTP of the XAML Toolkit.&#160; This should make analysis of XAML for both .NET &#38; Silverlight very easy to do.&#160; We&#8217;re adding some preliminary FxCop integration for XAML and allowing you to write your own custom rules.
Our talk will be published here in the near future and you can go [...]]]></description>
			<content:encoded><![CDATA[<p>At PDC, we&#8217;re announcing a CTP of the XAML Toolkit.&#160; This should make analysis of XAML for both .NET &amp; Silverlight very easy to do.&#160; We&#8217;re adding some preliminary FxCop integration for XAML and allowing you to write your own custom rules.</p>
<p>Our talk will be published <a href="http://microsoftpdc.com/Sessions/CL24">here</a> in the near future and you can go through our presentation.</p>
<p>The components that are shipping as part of the November 2009 CTP are:</p>
<ul>
<li>XamlDom &#8211; A XAML DOM that is LINQ friendly.&#160; Enables easy static analysis. </li>
<li>XAML FxCop integration &#8211; A BaseXamlRule implementation that allows you to write custom FxCop rules that target XAML.&#160; We&#8217;re also shipping a couple of simple ones including a ValidationRule that will validate your XAML. </li>
<li>SilverlightSchemaContext &#8211; A XamlSchemaContext that allows System.Xaml to parse Silverlight XAML for tools use.&#160; </li>
<li>UISchemaContext &#8211; A XamlSchemaContext that allows you to go between .NET &amp; Silverlight XAML.&#160; This allows you to write custom FxCop rules that can be written against one framework but works against both platforms. </li>
</ul>
<p>I’ll dive into more detail on each of the components in the next few weeks.</p>
<p>Here&#8217;s a simple example of going through a document and writing out all the types used in the file:</p>
<p>&#160;</p>
<pre class="code"><span style="color: #2b91af">XamlDomObject </span>rootObject = <span style="color: #2b91af">XamlDomServices</span>.Load(<span style="color: #a31515">&quot;Window1.xaml&quot;</span>);

<span style="color: blue">foreach </span>(<span style="color: #2b91af">XamlDomObject </span>domObject <span style="color: blue">in </span>rootObject.DescendantsAndSelf())
{
  <span style="color: #2b91af">Console</span>.WriteLine(domObject.Type);
}</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p>&#160;</p>
<p>By calling XamlDomServices.Load, we get a XamlDomObject for the root object in the XAML document.&#160; From there, we can call DescendantsAndSelf on the root object which returns an IEnumerable&lt;XamlDomObject&gt; that you can loop through.</p>
<p>Here&#8217;s another example.&#160; Imagine you want to set Background on every single Control in your document but only the ones that don&#8217;t already have one set currently:</p>
<p>&#160;</p>
<pre class="code"><span style="color: #2b91af">XamlDomObject </span>rootObject = <span style="color: #2b91af">XamlDomServices</span>.Load(<span style="color: #a31515">&quot;Window1.xaml&quot;</span>);
<span style="color: blue">foreach </span>(<span style="color: #2b91af">XamlDomObject </span>objectNode <span style="color: blue">in
        from </span>control <span style="color: blue">in </span>rootObject.DescendantsAndSelf(<span style="color: blue">typeof</span>(<span style="color: #2b91af">Control</span>))
        <span style="color: blue">where </span>!control.HasMember(<span style="color: #a31515">&quot;Background&quot;</span>)
        <span style="color: blue">select </span>control)
{
  objectNode.SetMemberValue(<span style="color: #a31515">&quot;Background&quot;</span>, <span style="color: #a31515">&quot;Red&quot;</span>);
}
<span style="color: #2b91af">XamlDomServices</span>.Save(rootObject, <span style="color: #a31515">&quot;NewFile.xaml&quot;</span>);</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p><code></code></p>
<p>Like before, we&#8217;re calling DescendantsAndSelf but this time we&#8217;re passing in typeof(Control).&#160; This will limit it to return only things that are assignable to Control.&#160; We&#8217;re also using LINQ to be able to get the XamlDomObjects we want faster.&#160; After we call DescendantsAndSelf, we&#8217;ll then call &#8216;where !control.HasMember(&quot;Background&quot;)&#8217;.&#160; This limits it to only objects that don&#8217;t have a member called &quot;Background&quot; set on it currently. We select only those Controls.&#160; We then call SetMemberValue(&quot;Background&quot;, &quot;Red&quot;) to set the background property to Red.&#160; Finally, we call XamlDomServices.Save to save the file back out to XAML.&#160; This is a pretty simple example of a transformation but we can do much more complex transformations with our XamlDom.</p>
<p>Over the next few weeks, I&#8217;m going to try to post a couple of examples of using the XamlDom and FxCop.&#160; If you have any requests, please feel free to leave a comment/message.</p>
<p>The XAML Toolkit CTP can be found <a href="http://code.msdn.microsoft.com/XAML">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://michaelshim.com/blog/2009/11/19/xaml-toolkit-ctp/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
