<?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>Jeff Wilcox &#187; WPF</title>
	<atom:link href="http://www.jeff.wilcox.name/topics/dev/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeff.wilcox.name</link>
	<description>Silverlight, rich client apps and web development</description>
	<lastBuildDate>Mon, 26 Jul 2010 17:56:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>AutoCompleteBox: Now with 100% more WPF</title>
		<link>http://www.jeff.wilcox.name/2010/02/wpfautocompletebox/</link>
		<comments>http://www.jeff.wilcox.name/2010/02/wpfautocompletebox/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:11:04 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/02/wpfautocompletebox/</guid>
		<description><![CDATA[The AutoCompleteBox control I originally developed for the Silverlight Toolkit is now inside of the WPF Toolkit.]]></description>
			<content:encoded><![CDATA[<p>Thanks to the work of the WPF Toolkit team (and especially <a href="http://blogs.msdn.com/patrickdanino/">Patrick Danino</a>), the February 2010 release of the WPF Toolkit includes as new components <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.autocompletebox(VS.95).aspx">AutoCompleteBox</a>, plus Accordion and Rating as well.</p>
<p><a href="http://wpf.codeplex.com/releases/view/40535"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="AutoCompleteBoxWpf" border="0" alt="AutoCompleteBoxWpf" src="http://www.jeff.wilcox.name/wp-content/uploads/2010/02/AutoCompleteBoxWpf.png" width="618" height="664" /></a>     <br /><em>A WPF app that is running one of the AutoCompleteBox samples borrowed from the Silverlight Toolkit samples project, showing major airport names in a drop-down.</em></p>
<h3><a href="http://wpf.codeplex.com/releases/view/40535">Download the WPF Toolkit (February 2010 Release)</a></h3>
<h4>Resources</h4>
<ul>
<li><a href="http://www.bing.com/search?cp=1252&amp;FORM=FREESS&amp;q=autocompletebox&amp;q1=site%3Awww.jeff.wilcox.name">All of my AutoCompleteBox-related blog posts</a></li>
<li>Posts about this release: <a href="http://blogs.msdn.com/delay/archive/2010/02/22/this-is-what-happens-when-two-toolkits-fall-in-love-the-february-2010-release-of-the-wpf-toolkit-is-now-available.aspx">David Anson’s</a>, <a href="http://blogs.msdn.com/patrickdanino/archive/2010/02/22/wpf-toolkit-released.aspx">Patrick Danino’s</a></li>
</ul>
<p><em>And a quick aside… </em>when we began our <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> journey a few years ago, we became immediate advocates within the organization for compatibility with WPF, often building our controls to cross-compile, even if we didn’t have an immediate shipping plan for the WPF builds. <a href="http://blogs.msdn.com/delay/">David</a> sort of led the way here by offering his own unofficial <a href="http://blogs.msdn.com/delay/archive/2009/11/30/two-birds-squared-silverlight-wpf-data-visualization-development-release-3-and-a-datavisualizationdemos-update.aspx">gray market versions</a> of his charting and data visualization controls for WPF.</p>
<p>It’s nice to see things get out there in a more official mechanism, I know of many people enjoying the new-and-improved WPF Toolkit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/02/wpfautocompletebox/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>WPF Toolkit: Charting release</title>
		<link>http://www.jeff.wilcox.name/2009/06/wpf-charting-release/</link>
		<comments>http://www.jeff.wilcox.name/2009/06/wpf-charting-release/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 20:04:41 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[MIX]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=417</guid>
		<description><![CDATA[The Silverlight Toolkit's chart controls have made their way into the WPF Toolkit! More details on David's blog.]]></description>
			<content:encoded><![CDATA[<p>Just passing along the word, if you caught my <a href="http://www.jeff.wilcox.name/2009/03/mymix09-session/">MIX &#8217;09 talk</a> this year (or grabbed the <a href="http://www.jeff.wilcox.name/2009/04/mix09-source/">sources</a>), I demonstrated the Silverlight Toolkit&#8217;s charting components running on WPF. At the time, I mentioned that we had high hopes to bring them into WPF, and that has finally happened!</p>
<p><img alt="Charting in WPF" src="http://media.jeff.wilcox.name/blog/mix09/HousingPricesWpfApp.png" class="alignnone" width="685" height="528" /></p>
<p>More on <a href="http://blogs.msdn.com/delay/archive/2009/06/25/wpf-charting-it-s-official-june-2009-release-of-the-wpf-toolkit-is-now-available.aspx">David Anson&#8217;s blog post</a> about the WPF charting components.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/06/wpf-charting-release/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sharing Source and Skills &#8211; Source download</title>
		<link>http://www.jeff.wilcox.name/2009/04/mix09-source/</link>
		<comments>http://www.jeff.wilcox.name/2009/04/mix09-source/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 19:30:15 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MIX]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=378</guid>
		<description><![CDATA[This post contains the sample app and control source code from Jeff Wilcox's MIX '09 talk, Sharing Skills and Code with Silverlight and WPF.]]></description>
			<content:encoded><![CDATA[<p>At the MIX &#8217;09 conference this year, I presented a talk, &#8220;<a href="http://www.jeff.wilcox.name/2009/03/mymix09-session/">Sharing Skills and Code with Silverlight &amp; WPF</a>&#8220;. Here&#8217;s the sample application and control source code that was used throughout the talk.</p>
<p>It demonstrates simple concepts for linking files from a Silverlight to WPF project, using partial classes and partial methods, preprocessor directives, and other tools to create projects that work throughout the Microsoft Client Platform.</p>
<h4>Silverlight sample application</h4>
<p><img alt="Silverlight Application" src="http://media.jeff.wilcox.name/blog/mix09/HousingPricesApp.png" title="Housing prices - Silverlight Application" width="685" height="620" /></p>
<h4>WPF sample application -100% the same source</h4>
<p><img alt="WPF Application" src="http://media.jeff.wilcox.name/blog/mix09/HousingPricesWpfApp.png" title="Housing prices - WPF Application" width="685" height="528" /></p>
<p><a href="http://media.jeff.wilcox.name/blog/mix09/SharingSkillsAndCode.zip">Download the samples</a> &#8211; Zip, 596 KB<br />
The Zip contains the following work:</p>
<ul>
<li>Toolbar control for Silverlight and WPF</li>
<li>Sample application for the Toolbox</li>
<li>Continuum application &#8211; same XAML and CS shared between a Silverlight and WPF application that uses the DataGrid, charting controls, and our custom Toolbar control</li>
<li>Value-add code, Awesome.cs, that adds some simple functionality to the WPF application only</li>
</ul>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/04/mix09-source/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Sharing skills and code with Silverlight and WPF: MIX ‘09 session video and deck</title>
		<link>http://www.jeff.wilcox.name/2009/03/mymix09-session/</link>
		<comments>http://www.jeff.wilcox.name/2009/03/mymix09-session/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 01:04:38 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MIX]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=321</guid>
		<description><![CDATA[Check out my Sharing Skills and Code with Silverlight and WPF talk from MIX '09. Yeah, what happens in Vegas doesn't always stay there!]]></description>
			<content:encoded><![CDATA[<p>What happens in Vegas doesn’t always stay there. On Friday, I gave a talk at the MIX ‘09 conference about sharing skills and code between Silverlight and Windows Presentation Foundation (WPF).</p>
<p>One of the most important messages that I had during the talk is the flexibility that the Microsoft Client Platform enables: you can be a Rich Internet App developer today, and build an enterprise Line of Business app tomorrow, since so many of the concepts, APIs, and ideas are shared between these frameworks.</p>
<p><a href="http://media.jeff.wilcox.name/blog/mix09/MIX09_Wilcox_T87F.pptx"><strong>Download</strong> session deck</a> (4.7 MB PowerPoint 2007)<br />
<strong>View</strong> the session on the VisitMix.com site: <a title="http://videos.visitmix.com/MIX09/T87F" href="http://videos.visitmix.com/MIX09/T87F">http://videos.visitmix.com/MIX09/T87F</a></p>
<p><a href="http://videos.visitmix.com/MIX09/T87F"><img src="http://media.jeff.wilcox.name/blog/mix09/SharingSkillsThumbnail.jpg" width="685" height="385" /></a></p>
<p>Check out other awesome <a href="https://content.visitmix.com/2009/sessions/?categories=Silverlight">Silverlight</a>, <a href="https://content.visitmix.com/2009/sessions/?categories=WPF">WPF</a>, and <a href="https://content.visitmix.com/2009/sessions/?categories=Expression">Expression</a>. Hope this helps. Let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/03/mymix09-session/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Gravatar control for Silverlight and WPF &#8211; source and control binaries</title>
		<link>http://www.jeff.wilcox.name/2009/03/gravatar-control/</link>
		<comments>http://www.jeff.wilcox.name/2009/03/gravatar-control/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 01:11:18 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=308</guid>
		<description><![CDATA[A control for Gravatars that works in Silverlight 2 and WPF. Download contains binaries and full open source code.]]></description>
			<content:encoded><![CDATA[<p><img alt="The Gravatar control in a WPF sample application." src="http://media.jeff.wilcox.name/blog/view/GravatarWpfListBox.png" title="The Gravatar control in action in WPF" align="right" width="306" height="231" />While adding Gravatar support to my blog comments yesterday, I realized that it is a nice candidate for a simple control or a Uri-to-image value converter for Silverlight, and also WPF.</p>
<p>In fact, any application with a user’s e-mail address, or a contact list, could benefit greatly by this functionality. It’s a sweet addition that just works and provides a rich experience in just a few minutes.</p>
<ul>
<li><a href="http://media.jeff.wilcox.name/blog/view/GravatarControls.zip">Download GravatarControls.zip</a> [74 K Zip. Binaries and source for Visual Studio 2008, <a href="http://www.microsoft.com/opensource/licenses.mspx#Ms-PL">Ms-PL open source</a>]</li>
</ul>
<p>Since only a hash is used of the e-mail, it is secure enough to work from any app, simply using a URL, and without having to worry about messy web services, authentication, or security issues. Even better, with Silverlight’s reliance on the web browser’s network stack, you get caching and other nice functionality for free.</p>
<p>I decided to quickly implement this as an actual custom control, so that I could take advantage of data binding with the Email field, and demonstrate some simple code sharing concepts. This could have easily been done with a few lines of code behind and an Image instead.</p>
<p>It is then super easy to add a Gravatar control within a data template anywhere that your business object has an e-mail (or other unique identifying field). <a href="http://en.gravatar.com/">Gravatar</a> even supports Identicons (enabled by default in my control implementation), that assign a pretty unique geometric image to the e-mail in the case that the user hasn’t <a href="http://en.gravatar.com/site/signup">setup their gravatar yet</a>.</p>
<p><img alt="Visual Studio and a WPF app" src="http://media.jeff.wilcox.name/blog/view/GravatarCider.png" title="Visual Studio and a WPF app" width="658" height="579" /></p>
<p>This means that you can add images of users without messy database image work, personalizing their e-mail contact list, and otherwise making things look nice, for very little cost. Add it to</p>
<ul>
<li>ListBox </li>
<li>AutoCompleteBox </li>
<li>ComboBox </li>
<li>DataGrid </li>
<li><em>you name it!</em> </li>
</ul>
<p>So, to use the control, just make sure to define an xmlns attribute for the control assembly, then just set the Email dependency property value. A few other properties are also available, and you should set the Height and Width to typically a square. Ratings and a default image Uri are also supported through other properties. When setting the Email property in Expression Blend or even Visual Studio at design time, you’ll even get the image in there.</p>
<p><a href="http://en.gravatar.com/site/implement/url">Here’s implementation details</a> on the URL format that Gravatar uses, and is implemented by this control.</p>
<p>When using the control in code behind or XAML, you’ll find it 100% compatible between WPF and Silverlight. Easy. What’s next? Here’s how it was done…</p>
<h3>Building the Silverlight control to be WPF-compatible</h3>
<p>There are a few steps I took throughout the process to make the control WPF-compatible enough that I could cross-compile the same source code and XAML template. Here are the steps I took.</p>
<h4>XAML namespace</h4>
<p>To create an application or control that works in WPF and Silverlight, you need to use the following XML namespace declaration:</p>
<pre class="xml" name="code">
&lt;ResourceDictionary
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; /&gt;
</pre>
<p>This is one of those simple steps that I can’t stress enough!</p>
<h4>File links</h4>
<p>The Silverlight project serves as the “master” control, and the WPF project uses file links to reference the source files from the Silverlight project. This enables easy reuse, since making a change in one project immediately affects the next build of the other project type.</p>
<p>Since the Silverlight subset provides a good migration path, you typically will want to:</p>
<ul>
<li>Create the Silverlight control project and implementation</li>
<li>Create the WPF custom control library project in a peer folder</li>
<li>Add links in VS to the source files</li>
<li>Fix up and build as needed!</li>
</ul>
<h4>Default style key</h4>
<p>For custom controls, the default style information that hooks up Generic.xaml’s default control template and style is set using default style keys. WPF uses a one-time static constructor for this, while Silverlight uses a per-instance DefaultStyleKey setter.</p>
<p>This is easiest accomplished using pre-processor directives from C# for the SILVERLIGHT name that is defined by the Silverlight project types and build tools.</p>
<pre class="c-sharp" name="code">
#if !SILVERLIGHT
        /// &lt;summary&gt;
        /// Static initializer for the Gravatar type.
        /// &lt;/summary&gt;
        static Gravatar()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(Gravatar), new FrameworkPropertyMetadata(typeof(Gravatar)));
        }
#endif

        /// &lt;summary&gt;
        /// Initializes a new instance of the Gravatar control.
        /// &lt;/summary&gt;
        public Gravatar()
        {
#if SILVERLIGHT
            DefaultStyleKey = typeof(Gravatar);
#endif
            Loaded += (o, e) =&gt; ApplyTemplate();
        }
</pre>
<h4>MD5 implementation</h4>
<p>MD5 isn’t pretty, but it is simple and used across the web. I used <a href="http://blogs.msdn.com/delay/archive/2009/01/28/thank-goodness-for-reference-implementations-low-overhead-net-md5-implementation-source-code-and-tests-works-great-on-silverlight.aspx">David Anson’s implementation</a> of MD5 for Silverlight. For the WPF version, the standard MD5 code in System.Security.Cryptography is used.</p>
<h4>Generic theme and WPF</h4>
<p>Even though you can link in the Generic.xaml file that is 100% WPF source compatible, at build time, the resource won’t make its way properly into the metadata as “Themes\Generic.xaml”. To work around this, you’ll see in the WPF project that the linked Generic.xaml is in the root of the library, and contains the actual style information. WPF’s merged dictionary resource feature is then used inside a Themes\Generic.xaml file to pull in the linked Xaml content:</p>
<p>
<pre class="xml" name="code">
&lt;ResourceDictionary
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&gt;
    &lt;ResourceDictionary.MergedDictionaries&gt;
        &lt;ResourceDictionary Source=&quot;/Controls.Gravatar;component/generic.xaml&quot;/&gt;
    &lt;/ResourceDictionary.MergedDictionaries&gt;
&lt;/ResourceDictionary&gt;
</pre>
</p>
<p>Do note the assembly name in there. Hacky, but functional.</p>
<h4>Loading embedded resources</h4>
<p>If the image fails to load, the control falls back to use an embedded resource stream. This took some hacky code, which you’ll find in the source download. Effectively, on WPF, I needed to use a Jpeg bitmap image decoder, vs. Silverlight that has a simple centralized decoder that is not codec-specific.</p>
<p>I used simple #if SILVERLIGHT / #else / #endif preprocessor constructs to factor out the code differences.</p>
<h4>URL encoding</h4>
<p>Silverlight’s built in HttpUtility class is used for URL encoding as needed. This is the utility class found in the System.Windows.Browser namespace and assembly, and included with the runtime.</p>
<p>In WPF’s case, System.Web (ASP.NET)’s HttpUtility is used for the same exact functionality. There are opportunities for developers not looking to use a fallback URL image to factor this dependency and startup time peformance hit, I’m sure.</p>
<h4>Understand cross-scheme and Silverlight file access</h4>
<p>If you are working with a simple Silverlight application project and <em>not</em> through a web server or web project, you’ll likely see that the URL scheme at runtime is file://. This means that the images cannot be loaded cross-scheme, so this is perfectly normal operation:</p>
<p><img alt="What the fallback operation looks like for Silverlight cross-scheme" src="http://media.jeff.wilcox.name/blog/view/GravatarFallback.png" title="What the fallback operation looks like for Silverlight cross-scheme" width="227" height="307" /></p>
<p>As long as your final application will be hosted on a web server or corporate network server that uses the http:// scheme, your application should be fine.</p>
<h3>Download the control binaries and source code</h3>
<ul>
<li><a href="http://media.jeff.wilcox.name/blog/view/GravatarControls.zip">Download GravatarControls.zip</a> [74 K Zip. Binaries and source for Visual Studio 2008]</li>
</ul>
<p>The download contains simple samples, source projects for WPF and Silverlight, and release binaries. This code is licensed under the Microsoft Public License (Ms-PL).</p>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/03/gravatar-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
