<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>MHender Rambles On</title><link>http://blogs.msdn.com/mhendersblog/default.aspx</link><description>All you ever wanted to know about Windows Forms and Windows Presentation Foundation Interoperability (plus some other stuff).</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>I'm Hanging Up My Crossbow</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/05/09/593966.aspx</link><pubDate>Wed, 10 May 2006 00:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:593966</guid><dc:creator>mhender</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/593966.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=593966</wfw:commentRss><description>&lt;P&gt;My Dear Loyal Readers,&lt;/P&gt;
&lt;P&gt;That's right, I'm moving on to other projects here at Microsoft.&amp;nbsp; The Crossbow runtime is pretty well locked and loaded and on a glide path for release with WPF so I am shoving off for other shores.&amp;nbsp; Not to worry, Crossbow is in good hands and like I said it's pretty much in the can at this point.&lt;/P&gt;
&lt;P&gt;I have enjoyed stuffing my bits into your RSS readers and appreciated all the great comments and lively discussions.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Good luck and I'll most likely be blogging about some other topic soon...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=593966" width="1" height="1"&gt;</description></item><item><title>Crossbow Web Cast</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/04/05/569950.aspx</link><pubDate>Wed, 05 Apr 2006 23:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:569950</guid><dc:creator>mhender</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/569950.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=569950</wfw:commentRss><description>&lt;P&gt;I did a web cast, well really I guess it was a Live Meeting, today on Crossbow.&amp;nbsp; I received numerous requests to post my demos and my slide deck.&amp;nbsp; I'll do ya one better, I'll even post the recording of the event so you can watch it again and again.&amp;nbsp; Heck, ice down some brewskis and invite the whole freakin' neighborhood and make it a party...yeah a CROSSBOW party...that's the ticket!&amp;nbsp; Maybe...maybe...I could even get one of the networks to run it in prime time...maybe I could get my own CROSSBOW CHANNEL..huh, huh...yeah...that would be cool...huh, huh...MAYBE I COULD LAUNCH MY OWN SATELLITES THAT BROADCAST ALL CROSSBOW ALL THE TIME!&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture569321.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/569321/thumb.aspx" border=0&gt;&lt;/A&gt;&lt;A HREF="/photos/mhender/picture569321.aspx" target=_blank&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...(Note to self: don't forget to take your medication on time)&lt;/P&gt;
&lt;P&gt;Okay, I'm better now...enjoy and bring me some T.P.!&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.windowsforms.net/blogs/mhendersblog/april%205%20Post/Crossbow%20Runtime.ppt"&gt;Presentation Slide Deck&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.windowsforms.net/blogs/mhendersblog/april%205%20Post/RecipeBrowserFebCTP.zip"&gt;RecipeBrowser Demo&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.windowsforms.net/blogs/mhendersblog/april%205%20Post/WPFWithWFAndDatabindingFebCTP.zip"&gt;DatabindingDemo&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.windowsforms.net/blogs/mhendersblog/april%205%20Post/RD_Crossbow_talk.wmv"&gt;Recording of the Presentation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;P.S., you will need the Feb CTP of WPF and Crossbow to run the demos.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=569950" width="1" height="1"&gt;</description></item><item><title>Have You Checked the Children?</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/04/04/568350.aspx</link><pubDate>Tue, 04 Apr 2006 21:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:568350</guid><dc:creator>mhender</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/568350.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=568350</wfw:commentRss><description>&lt;P&gt;He says in his best maniacal voice...&lt;/P&gt;
&lt;P&gt;I assume you know that the fairly recent movie "When a Stranger Calls" is a re-make of the 1979 original which starred Carol Kane as the babysitter.&amp;nbsp; You may remember Carol Kane as Simka, Latka Gravas' (Andy Kaufman) wife in the TV show Taxi.&amp;nbsp; Andy's dead now you know...sad really...he kind of went off the deep end when he started wrestling women...&lt;/P&gt;
&lt;P&gt;Blog reader: What the hell are you talking about?&lt;/P&gt;
&lt;P&gt;Sorry, my mind wanders like that from time to time.&amp;nbsp; Don't know if it's because I'm a product of the 60's or if I'm just getting old or that I'm just plain out of my FREAKIN' gourd!&lt;/P&gt;
&lt;P&gt;Okay, I'm better now.&amp;nbsp; So anyway, I wanted to give you a heads up that there is a breaking change coming in the Crossbow API for Beta2.&amp;nbsp; There used to be a &lt;STRONG&gt;Children&lt;/STRONG&gt; property on WindowsFormsHost control.&amp;nbsp; You would use the property to add your subsequent Windows Forms control to the host via the Children.Add() method.&amp;nbsp; We'll it ain't there anymore.&amp;nbsp; We replaced it with a &lt;STRONG&gt;Child&lt;/STRONG&gt; property.&amp;nbsp; This was done because we felt it was kinda stupid to have a collection property that limited you to one item.&amp;nbsp; (You may remember that even though we implemented this property as a collection, we enforced a limitation of a single item in the collection).&amp;nbsp; So now there's just the single Child property and you simply assign some Windows Forms control to it.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;WindowsFormsHost&lt;/FONT&gt;&lt;FONT size=2&gt; host = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;WindowsFormsHost&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Windows.Forms.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Button&lt;/FONT&gt;&lt;FONT size=2&gt; wfButton = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; System.Windows.Forms.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Button&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wfButton.Text = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"WFButton"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;host.Child = wfButton;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Likewise on the ElementHost control, we used to have the &lt;STRONG&gt;Controls&lt;/STRONG&gt; collection property where you added your single top-level element.&amp;nbsp; Now we have replaced that with a &lt;STRONG&gt;Child&lt;/STRONG&gt; property as well.&amp;nbsp; Once again, we just wanted to remove the collection and replace it with a singleton and maintained consistency with the naming.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ElementHost&lt;/FONT&gt;&lt;FONT size=2&gt; host = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ElementHost&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Windows.Controls.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Button&lt;/FONT&gt;&lt;FONT size=2&gt; wpfButton = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; System.Windows.Controls.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Button&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;wpfButton.Content = &lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"WPFButton"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;host.Child = wpfButton;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Note that this change goes into effect in the Beta2 drop of Crossbow.&lt;/P&gt;
&lt;P&gt;&amp;lt;ManiacalVoice&amp;gt;&lt;BR&gt;So next time when the compiler calls and tells you something's wrong...remember to check the children...&lt;BR&gt;&amp;lt;/ManiacalVoice&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=568350" width="1" height="1"&gt;</description></item><item><title>Localizing a Hybrid Application</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/30/565040.aspx</link><pubDate>Thu, 30 Mar 2006 19:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:565040</guid><dc:creator>mhender</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/565040.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=565040</wfw:commentRss><description>&lt;DIV id=NowPlaying&gt;
&lt;DIV id=Intro&gt;I'm blogging to:&lt;/DIV&gt;
&lt;DIV id=Image&gt;&lt;A title="Check out KEXP" href="http://www.kexp.org/"&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id=Artist&gt;
&lt;H5&gt;KEXP&lt;/H5&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture565047.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/565047/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;
&lt;DIV id=Album&gt;
&lt;H5&gt;Live Stream&lt;/H5&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Have you ever done one of those things where you search all over the house looking for your glasses and after hours of searching you walk past a mirror and see that they are sitting on your head!&amp;nbsp; Makes you feel kinda stupid doesn't it?&amp;nbsp; Well, that's how I felt when I finally figured out how to localize a hybrid application yesterday.&amp;nbsp; I'd been struggling with this for some time and just couldn't get it to work and then finally it dawned on me which led me to utter the ultra-famous Homer Simpson phrase...D'oh!&lt;/P&gt;
&lt;P&gt;Here's the situation...You are building a Windows Forms application that you want to contain some WPF content as well.&amp;nbsp; Now you also want to localize this application so that it can be used in multiple locales.&amp;nbsp; Normally, you would want to create a main assembly for your default language and satellite assemblies for the localized content.&lt;/P&gt;
&lt;P&gt;So you set off on the journey, a regular Bilbo Baggins leaving theShire behind as you head toward your destiny.&lt;/P&gt;
&lt;P&gt;To frame this discussion, we will develop a useless little application purely for illustrative purposes.&amp;nbsp; Lets create a Windows Forms app called SimpleLocTest that contains a single form.&amp;nbsp; On that form, let's put a label and set its text to some English text...we'll use "English".&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Next we'll use the Windows Forms designer to localize our form.&amp;nbsp; Of course there are other ways to localize the form, but this way is easy.&amp;nbsp; To do this, set the Localizable property of the form to TRUE and change the Language property of the form to say Spanish (Spain).&amp;nbsp; Now change the text of the label to contain some Spanish text, yep we're going to use "Spanish".&amp;nbsp; Yeah, I'm clever like that.&lt;/P&gt;
&lt;P&gt;Okay, that takes care of localizing the Windows Forms stuff, now let's work on the WPF stuff.&amp;nbsp; First we need to add an ElementHost control to our form to host the content.&amp;nbsp; Next we will add a WPF UserControl item to our project.&amp;nbsp; Do this by adding a New Item to your project and choosing WinFx UserControl from the dialog.&amp;nbsp; This will create a UserControl1.xaml and a UserControl1.xaml.cs file in your project.&lt;/P&gt;
&lt;P&gt;Next let's modify the xaml of our UserControl to simply add a WPF Button to it.&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Uid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;UserControl_1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SimpleLocTest.UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;A href="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Button&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Content&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Hello&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Build and run the application and you should see all Englsh text.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture565028.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/565028/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Okay, now we want to set ourselves up for the case where we are running on a Spanish localized version of the OS.&amp;nbsp; We'll simulate this by changing the UICulture of our application's thread so that it thinks we are running on a Spanish OS.&amp;nbsp; To do this, add the following line of code to the form's constructor BEFORE the call to InitializeComponent():&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;System.Threading.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Thread&lt;/FONT&gt;&lt;FONT size=2&gt;.CurrentThread.CurrentUICulture = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; System.Globalization.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;CultureInfo&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"es-ES"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Next we need to go through the localization procedure for the WPF content.&amp;nbsp; To do this, we will follow the steps oulined in the WinFx SDK documentation for Localizing an Application under the WPF node in the docs.&lt;/P&gt;
&lt;P&gt;The first step is to add &lt;/P&gt;&lt;PRE&gt;&amp;lt;UICulture&amp;gt;en-US&amp;lt;/UICulture&amp;gt;&lt;/PRE&gt;
&lt;P&gt;to our .csproj file.&amp;nbsp; Wanna know a cool and easy way to hand modify your .csproj file while it is loaded in the Visual Studio IDE?&amp;nbsp; Just right-click on the project name in the Solution Explorer and choose Unload Project from the context menu.&amp;nbsp; Then right-click again on the project name and choose Edit SimpleLocTest.csproj from the context menu.&amp;nbsp; Now you can use the XML editor to work on the project file while still in the IDE. &lt;/P&gt;
&lt;P&gt;So we'll add this UICulture tag to to the top ProperyGroup which will mean it is for the debug configuration since we'll stay in the debug mode all the way through.&amp;nbsp; Of course you can add it to any of the configurations.&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;PropertyGroup&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Configuration&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Condition&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; '$(Configuration)' == '' &lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Debug&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Configuration&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Platform&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Condition&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; '$(Platform)' == '' &lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;AnyCPU&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Platform&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;ProductVersion&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;8.0.50727&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;ProductVersion&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;SchemaVersion&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;2.0&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;SchemaVersion&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;ProjectGuid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{828F16E3-20A4-4EC4-A8F4-CD95B8ED44C9}&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;ProjectGuid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;OutputType&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;WinExe&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;OutputType&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;AppDesignerFolder&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Properties&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;AppDesignerFolder&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;RootNamespace&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;SimpleLocTest&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;RootNamespace&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;AssemblyName&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;SimpleLocTest&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;AssemblyName&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UICulture&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;en-US&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UICulture&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;PropertyGroup&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Adding this tag will tell WPF that we want to generate satellite assemblies.&amp;nbsp; Now save the file and then right-click again on the project name and choose Reload Project from the context menu.&lt;/P&gt;
&lt;P&gt;Next we need to a Uids to our XAML file.&amp;nbsp; This makes it easy to identify each element and makes it easy for them to be localized.&amp;nbsp; To do this, you simple use MSBuild to build the application using the following syntax:&lt;/P&gt;
&lt;P&gt;msbuild /t:updateuid SimpleLocTest.csproj&lt;/P&gt;
&lt;P&gt;After running this command, your XAML file will now contain Uids.&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Uid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;UserControl_1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;SimpleLocTest.UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Uid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Grid_1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Button&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Uid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Button_1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Content&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Hello&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Okay, rebuild the application.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Time to do battle with an Orc or two.&amp;nbsp; Now we need to user the LocBaml tool to extract the resources that we can localize.&amp;nbsp; Go to the obj\debug directory of our project.&amp;nbsp; Run the following:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-fareast"&gt;LocBaml /parse SimpleLocTest.g.en-US.resources /out:foo.csv&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This will read in the resources that were generated as a result of adding the UICulture tag to our project file.&amp;nbsp; Note that these are the English resources.&amp;nbsp; This command will create a .CSV file that will allow you to use an editor like Excel or Notepad to edit the strings to change them to your localized language.&lt;/P&gt;
&lt;P&gt;Edit foo.csv.&amp;nbsp; You will find the string "Hello".&amp;nbsp; Change this to "Hola" and save the file back out over itself.&amp;nbsp; Next you need to merge the Spanish resources back into the English resources by running LocBaml again:&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-fareast"&gt;LocBaml /generate /trans:foo.csv SimpleLocTest.g.en-US.resources /out:c:\ /cul:es-ES&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This will generate a file called SimpleLocTest.g.es-ES.resources in the location c:\.&amp;nbsp; You can specify a different output directory, but I'm lazy at typing long paths so I just put it at the root.&amp;nbsp; Now I need to copy that file from c:\ to where the rest of my resources live just for convenience sake.&amp;nbsp; So copy c:\SimpleLocTest.g.es-ES.resources to our obj\debug directory.&lt;/P&gt;
&lt;P&gt;Next we need to merge the Windows Forms Spanish resources with the WPF Spanish resources to create our Spanish satellite assembly.&amp;nbsp; To do this, we use the linker (Al.exe):&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-fareast"&gt;Al.exe /out:SimpleLocTest.resources /culture:es-ES /embed:SimpleLocTest.Form1.es-ES.resources /embed:SimpleLocTest.g.es-ES.resources&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;This will generate a file called SimpleLocTest.resources.dll in the obj\debug directory.&amp;nbsp; We need to copy this file to the bin\debug\es-ES\ directory writing over the file of the same name that is already there.&amp;nbsp; Note that the file that is there is a satellite assembly that only contains Windows Forms Spanish resources that gets generate as part of the build process.&amp;nbsp; We can get rid of that file because we need the merged satellite assembly file.&lt;/P&gt;
&lt;P&gt;Now let's &lt;STRONG&gt;RUN&lt;/STRONG&gt; the application, &lt;STRONG&gt;DONT REBUILD IT&lt;/STRONG&gt; or you will write over the Spanish satellite assembly that we just worked so hard to build.&lt;/P&gt;
&lt;P&gt;You should now see the Spanish text for both the Windows Forms label and the WPF button:&lt;/P&gt;&lt;A HREF="/photos/mhender/picture565036.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/565036/original.aspx" border=0&gt;&lt;/A&gt; 
&lt;P&gt;THE PRECIOUS!&amp;nbsp; Okay, we made it unscathed!&amp;nbsp; And as you can see we were able to create a single Spanish satellite assembly that contains both Windows Forms and WPF resources.&amp;nbsp; Kinda like "...one satellite assembly to rule them all..."&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=565040" width="1" height="1"&gt;</description></item><item><title>We Don't Need No Stinking Mapping PI!</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/28/563153.aspx</link><pubDate>Tue, 28 Mar 2006 19:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:563153</guid><dc:creator>mhender</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/563153.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=563153</wfw:commentRss><description>&lt;DIV id=NowPlaying&gt;
&lt;DIV id=Intro&gt;I'm blogging to:&lt;/DIV&gt;
&lt;DIV id=Image&gt;&lt;A title="Check out The Yeah Yeah Yeahs" href="http://www.yeahyeahyeahs.com/"&gt;&lt;IMG src="http://images.amazon.com/images/P/B000EHQ7L0.01._SCTHUMBZZZ_.jpg"&gt;&lt;/IMG&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id=Artist&gt;
&lt;H5&gt;The Yeah Yeah Yeahs&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV id=Album&gt;
&lt;H5&gt;Show Your Bones&lt;/H5&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I just wanted to make sure eveyone was aware of this little fact.&amp;nbsp; First of all, in more recent builds (at leas the Feb CTP and beyond) you no longer use Mapping PIs to reference external assemblies.&amp;nbsp; Instead, you simply use the xmlns attribute by itself.&amp;nbsp; So using "old school" syntax you would have something like:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;?&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Mapping&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#808080 size=2&gt;XmlNamespace="wf" ClrNamespace=System.Windows.Forms" Assembly="System.Windows.Forms" &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;?&amp;gt;&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;MappingPIChange.Window1&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;A href="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;A href="http://schemas.microsoft.com/winfx/2006/xaml"&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color=#ff0000 size=2&gt;xmlns:wf&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;wf&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;/FONT&gt;
&lt;P&gt;Now you would loose the Mapping PI altogether and just use the xmlns attribute in the following manner:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;MappingPIChange.Window1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns:wf&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms&lt;/FONT&gt;&lt;FONT size=2&gt;"&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Furthermore, you do not need to do this at all for the things in WindowsFormsIntegration such as WindowsFormsHost.&amp;nbsp; These are now part of the standard schema and no longer need to be prefixed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=563153" width="1" height="1"&gt;</description></item><item><title>Dude, Where's My Control?</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/27/562126.aspx</link><pubDate>Mon, 27 Mar 2006 19:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:562126</guid><dc:creator>mhender</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/562126.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=562126</wfw:commentRss><description>&lt;DIV id=NowPlaying&gt;
&lt;DIV id=Intro&gt;I'm blogging to:&lt;/DIV&gt;
&lt;DIV id=Image&gt;&lt;A title="Check out Johnny Cash" href="http://www.johnnycash.com/"&gt;&lt;IMG src="http://ec1.images-amazon.com/images/P/B000BISBDY.01._SCTHUMBZZZ_.jpg"&gt; &lt;/IMG&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id=Artist&gt;
&lt;H5&gt;Johnny Cash&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV id=Album&gt;
&lt;H5&gt;The Legend of Johnny Cash&lt;/H5&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;I have received numerous emails from people who are using the Feb CTP version of Crossbow and have run into the bug that we have in ElementHost where the hosted WPF content does not show up until you resize the Form that contains the ElementHost control. &lt;/P&gt;
&lt;P&gt;While this may be a small enough issue, many people have requested a work-around for the problem.&amp;nbsp; Well, you would think that all you have to do is force a repaint by calling Invalidate() or Refresh() on the Form, but alas this does not make the content appear.&amp;nbsp; So how can we fix this?&lt;/P&gt;
&lt;P&gt;Don't fret my little Crossbow consumers...Uncle Mike is here to hook you up.&amp;nbsp; Here's what you need to do...At the end of your Form_Load() event handler, hook the Shown event and change the Form's size.&amp;nbsp; So, something like:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Form1_Load(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;object&lt;/FONT&gt;&lt;FONT size=2&gt; sender, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;EventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e) {&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ElementHost&lt;/FONT&gt;&lt;FONT size=2&gt; host = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ElementHost&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Dock = &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DockStyle&lt;/FONT&gt;&lt;FONT size=2&gt;.Fill;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt; ctrl = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Controls.Add(ctrl);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;&lt;FONT size=2&gt;.Controls.Add(host);&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Here's the magic line of code&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shown += &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;delegate&lt;/FONT&gt;&lt;FONT size=2&gt; { Width++; };&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;This little hack will at least get you up and running so that you can see your hosted WPF content when the Form loads.&amp;nbsp; Generally, this will suffice until you get the version of Crossbow that has this fixed.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=562126" width="1" height="1"&gt;</description></item><item><title>Help me fix my CSS!</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/22/558093.aspx</link><pubDate>Wed, 22 Mar 2006 19:11:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:558093</guid><dc:creator>mhender</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/558093.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=558093</wfw:commentRss><description>&lt;DIV id=NowPlaying&gt;
&lt;DIV id=Intro&gt;I'm blogging to:&lt;/DIV&gt;
&lt;DIV id=Image&gt;&lt;A title="Check out Sirius" href="http://www.sirius.com/"&gt;&lt;IMG src="http://www.windowsforms.net/blogs/mhendersblog/loc.gif"&gt; &lt;/IMG&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id=Artist&gt;
&lt;H5&gt;Sirius Satellite Radio&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV id=Album&gt;
&lt;H5&gt;Left of Center&lt;/H5&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Okay all you CSS studs and studettes out there...help me out.&amp;nbsp; I'm having a CSS crisis!&amp;nbsp; If you are a regular reader of my blog you notice that I try to give you some insight into my strange mind by telling you what music I am listening to while I blog.&amp;nbsp; I created a schema for describing this information and then built some CSS that I thought would render it nicely over in the right hand margin of the page.&amp;nbsp; It works fine when you go to one specific post, but if you go to the page where all the blog posts are listed one after the other, the CSS doesn't work correctly.&amp;nbsp; So each post will have an entry for the music, but I only want it to show up for the top most post...you get what I'm saying?&amp;nbsp; So here's an example of the schema:&lt;/P&gt;
&lt;P&gt;&amp;lt;DIV id=NowPlaying&amp;gt;&lt;BR&gt;&amp;lt;DIV id=Intro&amp;gt;I'm blogging to:&amp;lt;/DIV&amp;gt;&lt;BR&gt;&amp;lt;DIV id=Image&amp;gt;&amp;lt;A title="Check out the Beatie Boys" href="&lt;A href="http://www.beastieboys.com%22%3e%3cimg/"&gt;http://www.beastieboys.com"&amp;gt;&amp;lt;IMG&lt;/A&gt; src="&lt;A href="http://images.amazon.com/images/P/B00021LRWM.01.THUMBZZZ.jpg%22%3E%3C/A%3E%3C/DIV"&gt;http://images.amazon.com/images/P/B00021LRWM.01.THUMBZZZ.jpg"&amp;gt;&amp;lt;/A&amp;gt;&amp;lt;/DIV&lt;/A&gt;&amp;gt;&lt;BR&gt;&amp;lt;DIV id=Artist&amp;gt;&lt;BR&gt;&amp;lt;H5&amp;gt;The Beastie Boys&amp;lt;/H5&amp;gt;&amp;lt;/DIV&amp;gt;&lt;BR&gt;&amp;lt;DIV id=Album&amp;gt;&lt;BR&gt;&amp;lt;H5&amp;gt;To The 5 Burroughs&amp;lt;/H5&amp;gt;&amp;lt;/DIV&amp;gt;&amp;lt;/DIV&amp;gt;&lt;BR&gt;&lt;/P&gt;
&lt;P&gt;Here's the CSS I'm using:&lt;/P&gt;
&lt;P&gt;#NowPlaying {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; position: absolute;&lt;BR&gt;&amp;nbsp;height: 200px;&lt;BR&gt;&amp;nbsp;width: 170px;&lt;BR&gt;&amp;nbsp;background-color: #DDDDCC;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; right: 0px;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; top: 400px;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; border: 1px;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; border-color: #770000;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; border-style: solid;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;#Intro, #Artist, #Album{&lt;BR&gt;&amp;nbsp;text-align: center;&lt;BR&gt;&amp;nbsp;color: #770000;&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;#Image{&lt;BR&gt;&amp;nbsp;margin-left: 50px;&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;How can I make just the top most "NowPlaying" div render and ignore any subsequent ones?&amp;nbsp; What happens instead is the bottom-most entry gets displayed (the last one) instead of the top-most entry (the first one).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=558093" width="1" height="1"&gt;</description></item><item><title>A Bitmap By Any Other Name...</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/17/554015.aspx</link><pubDate>Fri, 17 Mar 2006 21:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:554015</guid><dc:creator>mhender</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/554015.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=554015</wfw:commentRss><description>&lt;DIV id=NowPlaying&gt;
&lt;DIV id=Intro&gt;I'm blogging to:&lt;/DIV&gt;
&lt;DIV id=Image&gt;&lt;A title="Check out The Greencards" href="heep://www.thegreencards.com/"&gt;&lt;IMG src="http://images.amazon.com/images/P/B0009JDBKI.01._SCTHUMBZZZ_.jpg"&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id=Artist&gt;
&lt;H5&gt;The Greencards&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV id=Album&gt;
&lt;H5&gt;Weather and Water&lt;/H5&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;As I typed the title to this post, I wondered just how many people over the years have butchered "Billy the Bard"'s line from Romeo &amp;amp; Juliet?&amp;nbsp; I'm sure it's ridiculously high and here I go contributing to it.&amp;nbsp; Sorry about that Bill, you can roll back over in your grave now...&lt;/P&gt;
&lt;P&gt;In the spirit of interoperability, I thought it may be interesting to take a look at a scenario where you want to write a WPF application that uses resources that are entered and stored via the Resource Editor in Visual Studio.&lt;/P&gt;
&lt;P&gt;Let's create a cheesy little application that shows off how to do this.&amp;nbsp; First we need to create a WPF application using VS.&amp;nbsp; Then we add some resources using the Resource Editor.&amp;nbsp; To do that we just go over to our Solution Explorer in VS, expand the Properties node and double-click on 'Resources.resx'.&amp;nbsp; This will launch the Resource Editor.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553943.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553943/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In the Resource Editor, let's add a string resource and an image resource.&amp;nbsp; For the string, we will use some lyrics to one of my favorite Soul Coughing songs 'Screenwriters Blues'.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553945.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553945/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Since we are using these lyrics, let's use the image of the 'Ruby Vroom' CD that the song is on as our resource image.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553946.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553946/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Okay, now that we have our resources stored, let's work on the rest of the app.&amp;nbsp; Let's go to our XAML and add a Button and a Label.&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;stackPanel1&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&lt;/FONT&gt;...&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Button&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;button1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Margin&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;0,10,0,0&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;label1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;...&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;What we are going to do is use the string from our resources for the Label and use the image as the background of our button.&amp;nbsp; Now using the string is perfectly straight forward since a string is a string.&amp;nbsp; The bitmap however is a horse of a different color or it smells different or something.&amp;nbsp; (Yeah, I know...I'm mixing my metaphors).&amp;nbsp; &lt;/P&gt;
&lt;P&gt;So let's go to the code behind to start doing our thing.&amp;nbsp; We need to figure out where we are going to put our logic to set the label and the button.&amp;nbsp; Usually you do this in some event handler in the code behind so we'll do that as well.&amp;nbsp; However, what event should we choose?Most of the time you see examples using the Loaded event for the Window so that would be normal for us to use as well.&amp;nbsp; BUT, I ain't gonna do that.&amp;nbsp; Why?&amp;nbsp; Well, it's because I want to be different and it's a good habit to get into.&amp;nbsp; Let me explain this a bit.&amp;nbsp; Many times in our code behind, we are doing things like adding controls to our visual tree in a WPF application.&amp;nbsp; And if we use the Loaded event handler for doing this, we can sometimes get undesireable results.&amp;nbsp; For example, if we are using a parent control such as a StackPanel and if we were to handle the Loaded event and put logic there to add controls, you would see that the Loaded event fires more than once due to the re-layout of the window after each control is added.&amp;nbsp; This would result in having the controls added multiple times.&amp;nbsp; If we instead use the SourceInitialized event, we don't have this problem because it is fired only once.&lt;/P&gt;
&lt;P&gt;Okay, in our code behind let's handle the SourceInitialized event and put our code there.&amp;nbsp; The first thing we want to do is get our resources.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Get the resources&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;System.Drawing.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Bitmap&lt;/FONT&gt;&lt;FONT size=2&gt; resourceBitmap = Properties.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Resources&lt;/FONT&gt;&lt;FONT size=2&gt;.ruby;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt; resourceString = Properties.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Resources&lt;/FONT&gt;&lt;FONT size=2&gt;.String1;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Next let's do set our label's content to be the value in our string resource.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Set the label's content to be our resource string&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.label1.Content = resourceString;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Now comes the part that's just a bit trickier...setting our button's background to our resource image.&amp;nbsp; It's only tricky because the resource happens to be of type System.Drawing.Bitmap and we cannot set our button's background to a System.Drawing.Bitmap.&amp;nbsp; To do this, we have to convert the bitmap to something that WPF understands.&amp;nbsp; Luckly, there is a helper function that makes this a bit easier.&amp;nbsp; The helper function is called 'CreateBitmapSourceFromHBitmap' which can be found in the System.Windows.Interop.Imaging namespace.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Convert the System.Drawing.Bitmap to a WPF BitmapSource that we can use&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IntPtr&lt;/FONT&gt;&lt;FONT size=2&gt; hBitmap = resourceBitmap.GetHbitmap();&lt;BR&gt;System.Windows.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Int32Rect&lt;/FONT&gt;&lt;FONT size=2&gt; rect = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Int32Rect&lt;/FONT&gt;&lt;FONT size=2&gt;(0, 0, resourceBitmap.Width, resourceBitmap.Height);&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;BitmapSource&lt;/FONT&gt;&lt;FONT size=2&gt; bmpSrc = System.Windows.Interop.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Imaging&lt;/FONT&gt;&lt;FONT size=2&gt;.CreateBitmapSourceFromHBitmap(hBitmap, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;IntPtr&lt;/FONT&gt;&lt;FONT size=2&gt;.Zero, rect, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;BitmapSizeOptions&lt;/FONT&gt;&lt;FONT size=2&gt;.FromEmptyOptions());&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Let's take a quick look at the function signature for this function:&lt;/P&gt;&lt;PRE xml:space="preserve"&gt;&lt;SPAN class=keyword&gt;public&lt;/SPAN&gt; &lt;SPAN class=keyword&gt;static&lt;/SPAN&gt; &lt;A href="ms-help://MS.MSSDK.1033/MS.WinFXSDK.1033/cpref33/html/T_System_Windows_Media_Imaging_BitmapSource.htm"&gt;BitmapSource&lt;/A&gt; &lt;SPAN class=identifier&gt;CreateBitmapSourceFromHBitmap&lt;/SPAN&gt; (
	&lt;?XML:NAMESPACE PREFIX = MSHelp NS = "http://msdn.microsoft.com/mshelp" /&gt;&lt;mshelp:link tabIndex=0 keywords="T:System.IntPtr" xmlns:mshelp="http://msdn.microsoft.com/mshelp"&gt;IntPtr&lt;/mshelp:link&gt; &lt;SPAN class=parameter&gt;bitmap&lt;/SPAN&gt;,
	&lt;mshelp:link tabIndex=0 keywords="T:System.IntPtr" xmlns:mshelp="http://msdn.microsoft.com/mshelp"&gt;IntPtr&lt;/mshelp:link&gt; &lt;SPAN class=parameter&gt;palette&lt;/SPAN&gt;,
	&lt;mshelp:link tabIndex=0 keywords="T:System.Windows.Int32Rect" xmlns:mshelp="http://msdn.microsoft.com/mshelp"&gt;Int32Rect&lt;/mshelp:link&gt; &lt;SPAN class=parameter&gt;sourceRect&lt;/SPAN&gt;,
	&lt;A href="ms-help://MS.MSSDK.1033/MS.WinFXSDK.1033/cpref33/html/T_System_Windows_Media_Imaging_BitmapSizeOptions.htm"&gt;BitmapSizeOptions&lt;/A&gt; &lt;SPAN class=parameter&gt;sizeOptions&lt;/SPAN&gt;
)&lt;/PRE&gt;
&lt;P&gt;The first parameter is a pointer to our original bitmap as an HBITMAP.&amp;nbsp; In order to supply that we have to call the GetHBitmap() function on our System.Drawing.Bitmap object.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The next parameter is a pointer to the bitmap's palette.&amp;nbsp; Now we have a Palette property on our original bitmap object, but we can't pass it to this function because the function wants the palette as an IntPtr.&amp;nbsp; So to make this happen, you are going to have to write some magic code that will convert the color palette to an IntPtr.&amp;nbsp; (Actually, I tried this and never quite got it right).&amp;nbsp; But the good news is that since our bitmap does not have a specific palette, we can just pass in IntPtr.Zero (null).&lt;/P&gt;
&lt;P&gt;Next is the source rectangle for our bitmap.&amp;nbsp; Note that the function want this to be in the form of an Int32Rect and not a System.Drawing.Rectangle object.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;I don't totally understand what the final parameter is all about, but I played around with different settings and managed to get this working so I didn't worry about it too much.&lt;/P&gt;
&lt;P&gt;Okay, now that we have converted our bitmap to something that we can use, let's set the background of our button to the image and make sure the size of the button is the proper size.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008000 size=2&gt;// Set the background property of our button to the converted resource bitmap&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.button1.Background = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ImageBrush&lt;/FONT&gt;&lt;FONT size=2&gt;(bmpSrc);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.button1.Height = resourceBitmap.Height;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.button1.Width = resourceBitmap.Width;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Okay, now let's run the app and see what it looks like:&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture554012.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/554012/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Okay, just what we wanted huh?&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=554015" width="1" height="1"&gt;</description></item><item><title>Sharing...</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/16/553084.aspx</link><pubDate>Thu, 16 Mar 2006 19:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:553084</guid><dc:creator>mhender</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/553084.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=553084</wfw:commentRss><description>&lt;P&gt;Okay, now I'm really going to show my age...&amp;nbsp; If you're an old fart like me you remember the classic Cracker Jack commericals featuring character actor Jack Gilford where he succumbs to pressure from little kids to share his Cracker Jacks and the tag line was "Sharing...".&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture552949.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/552949/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Okay so you don't remember huh?&amp;nbsp; Anyway...the point of all of this is to talk about what else...&lt;STRONG&gt;&lt;EM&gt;sharing&lt;/EM&gt;&lt;/STRONG&gt;.&amp;nbsp; Specifically I want to talk about a Crossbow scenario where you may have a Windows Forms application that contains multiple ElementHost controls that each contain some WPF content and you want to use shared resources such as styles.&lt;/P&gt;
&lt;P&gt;So here's the deal...In a standard WPF application you usually hang resources off of some parent element and in doing so, child element will inherit these resources.&amp;nbsp; For example, say that we want all Labels in a WPF application to have a certain look.&amp;nbsp; To acheive this we would do something like this:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WindowsApplication160.Window1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Title&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WindowsApplication160&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Height&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;300&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Width&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;300&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Loaded&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WindowLoaded&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;sp1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel.Resources&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Style&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;TargetType&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;{x:Type Label}&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Setter&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Property&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FontSize&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Value&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;14&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Setter&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Property&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;FontWeight&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Value&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Bold&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Style&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel.Resources&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Hello&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Goodbye&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;This will define the style for all Labels that are children of the StackPanel.&amp;nbsp; So all Labels that are added to the StackPanel will all inherit the style so that they all look the same.&lt;/P&gt;
&lt;P&gt;Yeah, so...&amp;nbsp; Well the issue here is that say we have a Windows Forms application that contains some WPF content and you want to be able to create "global" styles for your elements.&amp;nbsp; Furthermore, you may have multiple instances of this or other WPF content spread across your Windows Forms application and you want them to all share common styles.&amp;nbsp; How do you do it?&amp;nbsp; The problem is that you don't have the ability to have application level XAML file (MyApp.xaml)&amp;nbsp;where you could define global styles.&lt;/P&gt;
&lt;P&gt;Well, it's really not difficult, you just have to know how to wire it all up.&amp;nbsp; So here's the deal... What you need to do is simply create a global ResourceDictionary to hang your global styles off of and then point all of your hosted WPF content to that ResourceDictionary.&lt;/P&gt;
&lt;P&gt;Let's take a look at this in more detail.&amp;nbsp; Say we have a WPF UserControl that consists of multiple Labels.&amp;nbsp; (Yeah, I know...it's totally contrived and you would never build something so stupid, but bear with me it's just for illustrative purposes).&amp;nbsp; So the XAML for your UserControl may look something like:&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;GlobalStyleSample.UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;http://schemas.microsoft.com/winfx/2006/xaml&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;stackPanel1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Label1&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Label2&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Label3&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT size=2&gt;Label4&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Label&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;StackPanel&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;UserControl&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Now suppose that we want to host this content on a Windows Form form multiple times and we want to globally define how the labels in the UserControls should look and we want each instance of the UserControl to have the same look.&lt;/P&gt;
&lt;P&gt;So let's host two instances of the UserControl on a Windows Form form using a SplitContainer to separate the two.&amp;nbsp; To do this, we need to first create the form and then drop a SplitContainer on the form.&amp;nbsp; Then we will put two ElementHost controls (one on each SplitterPanel).&amp;nbsp; Now, to make this easy for us to do, we're going to put the ElementHost control onto our Toolbox so that it will be easier for us to work at design time.&lt;/P&gt;
&lt;P&gt;To do this, right-click on the ToolBox and pick 'Choose Items...'&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553052.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553052/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Then you will see the 'Choose Toolbox Items' dialog box.&amp;nbsp; Here you will need to click the 'Browse' button to find the WindowsFormsIntegration dll that contains ElementHost.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553053.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553053/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Assuming that you are using the Feb CTP of Crossbow, you will find the dll in the Cider directory.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553056.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553056/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Next you will see the ElementHost control in the 'Choose Toolbox Items' dialog box.&amp;nbsp; Check the check box for the ElementHost control and click the OK button.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553059.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553059/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Now you should see the ElementHost control in the Toolbox.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553062.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553062/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Whew, you probably already knew how to do that anyway, but what the hell...&lt;/P&gt;
&lt;P&gt;Now that we have the ElementHost control on our Toolbox, let's put this thing together.&amp;nbsp; Let's drop a SplitContainer on our Form.&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553067.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553067/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Next we will put an ElementHost control on each of the panels of the SplitContainer.&amp;nbsp; Just drag and drop an ElementHost on each from the Toolbox.&amp;nbsp; Now, you will notice that the ElementHost gets rendered with its background color the same as the panels and without any borders.&amp;nbsp; This makes it look as though it's invisible once it is not selected.&amp;nbsp; If it bugs you that you cannot see the ElementHost when it is not selected, just set its background color to something else.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Okay, next lets select each ElementHost control and Dock Fill them so that they take up all the real estate of each panel.&amp;nbsp; Now we can put our WPF UserControls on the form by hosting them in each ElementHost.&amp;nbsp; Let's do this by going to the code behind in say the Form_Load event handler to do this.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Form1_Load(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;object&lt;/FONT&gt;&lt;FONT size=2&gt; sender, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;EventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt; uc1 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;&lt;FONT size=2&gt;.elementHost1.Controls.Add(uc1);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt; uc2 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;&lt;FONT size=2&gt;.elementHost2.Controls.Add(uc2);&lt;BR&gt;}&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Run the app and it should look something like:&lt;A HREF="/photos/mhender/picture553074.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553074/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Now we want to introduce our global Label style so that both instances of the UserControl uses the style for all of the labels.&amp;nbsp; We do this by creating a global ResourceDictionary and adding a style to it.&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;partial&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;class&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Form1&lt;/FONT&gt;&lt;FONT size=2&gt; : &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Form&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ResourceDictionary&lt;/FONT&gt;&lt;FONT size=2&gt; rd;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/FONT&gt;&lt;FONT size=2&gt; Form1()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InitializeComponent();&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rd = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;ResourceDictionary&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Style&lt;/FONT&gt;&lt;FONT size=2&gt; myLabelStyle = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Style&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(System.Windows.Controls.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Label&lt;/FONT&gt;&lt;FONT size=2&gt;));&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Setter&lt;/FONT&gt;&lt;FONT size=2&gt; fontSize = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Setter&lt;/FONT&gt;&lt;FONT size=2&gt;(System.Windows.Controls.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Label&lt;/FONT&gt;&lt;FONT size=2&gt;.FontSizeProperty, 14.0);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Setter&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;nbsp;fontWeght = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Setter&lt;/FONT&gt;&lt;FONT size=2&gt;(System.Windows.Controls.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Label&lt;/FONT&gt;&lt;FONT size=2&gt;.FontWeightProperty, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;FontWeights&lt;/FONT&gt;&lt;FONT size=2&gt;.Bold);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myLabelStyle.Setters.Add(fontSize);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myLabelStyle.Setters.Add(fontWeght);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rd.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;typeof&lt;/FONT&gt;&lt;FONT size=2&gt;(System.Windows.Controls.&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Label&lt;/FONT&gt;&lt;FONT size=2&gt;), myLabelStyle);&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Now we just need to point our UserControls to the ResourceDictionary object:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; Form1_Load(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;object&lt;/FONT&gt;&lt;FONT size=2&gt; sender, &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;EventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt; uc1 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;&lt;FONT size=2&gt;.elementHost1.Controls.Add(uc1);&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt; uc2 = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;UserControl1&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/FONT&gt;&lt;FONT size=2&gt;.elementHost2.Controls.Add(uc2);&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;uc1.Resources = uc2.Resources = rd&lt;/STRONG&gt;;&lt;BR&gt;}&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Let's run the app and see what happens now...&lt;/P&gt;
&lt;P&gt;&lt;A HREF="/photos/mhender/picture553079.aspx" target=_blank&gt;&lt;IMG src="/photos/mhender/images/553079/original.aspx" border=0&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Sweet!&amp;nbsp; Now all of the WPF labels in our Windows Forms application share the same style.&lt;/P&gt;
&lt;P&gt;Okay, I bet you are saying: "Hey, you could've just added that style to the definition of the UserControl in XAML and each instance of the UserControl in the app would share the Label's style".&amp;nbsp; Yep, in this particular case you're right.&amp;nbsp; However, what if the two instances of the UserControl were in fact two different UserControls for example.&amp;nbsp; In that case, I would have had to define the style in both XAML files.&amp;nbsp; This way I only have to define the style once in code behind and wire-up any WPF content to that style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=553084" width="1" height="1"&gt;</description></item><item><title>"I Love It When A Plan Comes Together!"</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/01/541422.aspx</link><pubDate>Wed, 01 Mar 2006 21:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:541422</guid><dc:creator>mhender</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/541422.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=541422</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;I just had to quote George Peppard’s cigar-chomping-glove-wearing character Col. Hannibal Smith from TVs “The A Team” because it seems so appropriate.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;One of the beautiful things about the software industry is the ecosystem that develops around it and the cycle of information flow between software companies and their customers.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So it is really exciting to see a situation where our customers provide important feedback to us and we are able to act on that feedback to better address a customer need.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;If you are a regular reader of my blog, you have heard me discuss our plans for shipping Crossbow in the “Orcas” product (the next release of Visual Studio).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Many of our customers were quick to respond to that information by letting us know that we needed to do whatever we could to ship Crossbow with WPF.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This makes sense of course since many customers are planning on delivering a WPF version of their application shortly after WPF ships and for some customers the control set of WPF lacks some key controls that Windows Forms has (like the DataGridView) and they need to rely on Crossbow in order to ship.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri&gt;Well, I’m happy to say you spoke and we listened!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We have spent the last several months working very hard on developing and executing on a plan where we could deliver the Crossbow runtime as an integral part of WPF.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As of the Beta2 release of WPF, the Crossbow runtime will be part of the WPF redist and reside in the GAC just like all of the other WPF components.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And from that point forward we will be on the WPF ship schedule which means that we will RTM with WPF.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%; FONT-FAMILY: Calibri; mso-fareast-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Thank you for your valuable feedback.&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=541422" width="1" height="1"&gt;</description></item><item><title>Crossbow on MSDN TV</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/03/01/541385.aspx</link><pubDate>Wed, 01 Mar 2006 20:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:541385</guid><dc:creator>mhender</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/541385.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=541385</wfw:commentRss><description>&lt;P&gt;Well my MSDN TV debut finally hit the airwaves.&amp;nbsp; I teased you a while back when I told you that it was coming (I didn't realize that it took so long for these to make it to the site).&amp;nbsp; I know you have been just trembling with anticipation, but tremble no more 'cause it &lt;A href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060216CrossbowMH/manifest.xml"&gt;here&lt;/A&gt;!&lt;/P&gt;
&lt;P&gt;Y'know they tell you that you look 10 pounds heavier when you are on camera?&amp;nbsp; Wow, how many cameras were on me anyway?&amp;nbsp; (Okay, I know, I stole that from a Friends episode)&amp;nbsp; Enjoy!&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=541385" width="1" height="1"&gt;</description></item><item><title>Good News...Bad News (kinda)</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/02/01/522723.aspx</link><pubDate>Thu, 02 Feb 2006 04:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:522723</guid><dc:creator>mhender</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/522723.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=522723</wfw:commentRss><description>&lt;p&gt;Hello again my Crossbow lovin' friends!&amp;nbsp; Well, I have good news and bad news...Well not really &lt;em&gt;bad&lt;/em&gt; news...you can judge for yourself.&lt;/p&gt;
&lt;p&gt;So, first the good news...&lt;/p&gt;
&lt;p&gt;We are releasing the Feb CTP version of Crossbow with many new changes.&amp;nbsp; Whether you know it or not, the code that we have been delivering in the CTPs since PDC have all been basically the same code base.&amp;nbsp; We finally we are updating what we are sending out via the CTPs with new up-to-date code.&amp;nbsp; Ah, don't you just love the smell of freshly cut code?&lt;/p&gt;
&lt;p&gt;So you may be wondering what new features we have added to the Crossbow runtime in this upcoming release.&amp;nbsp; Well, I'll give you a little tastly morsel:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Improved keyboard handling&lt;/li&gt;
&lt;li&gt;Improved focus management&lt;/li&gt;
&lt;li&gt;Extensible property mapping&lt;/li&gt;
&lt;li&gt;Other important plumbing stuff&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Sounds nice, doesn't it?&lt;/p&gt;
&lt;p&gt;Okay, so what's the bad news?&lt;/p&gt;
&lt;p&gt;Well, we have been trying hard to figure out how we are going to ship Crossbow.&amp;nbsp; That amounts to finding the right ship vehicle and doing all the infrastructure work that is required to "get on a release train" as we say (more on that in a later post).&amp;nbsp; This means that there has been some moving around of bits and such.&amp;nbsp; Yeah, yeah, get to the point...&amp;nbsp; Well what this means is that we are kind of in the middle of sorting some of these details out and we are kind of straddling both sides of a particular ship fence.&amp;nbsp; Therefore, in the Feb CTP, we are not only shipping once, but twice!&amp;nbsp; We are shipping in the WinFX SDK like we have been, but we are also shipping in Cider as part of Orcas CTP ("Fidalgo").&amp;nbsp; That means that if you install the Feb CTP, you will find two copies of our dll (WindowsFormsIntegration.dll) in two &lt;strong&gt;different&lt;/strong&gt; places on disk.&lt;/p&gt;
&lt;p&gt;Note that these are different versions of the dll.&amp;nbsp; For this release, you should ignore the version that is place in the "Program Files\Reference Assembly..." path and instead use the one that is in the "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Cider" directory.&lt;/p&gt;
&lt;p&gt;The SDK version of the dll is out of date code and in fact will not work if you are using XAML to instantiate Windows Forms controls due to a breaking change that was introduced by WPF in this release.&lt;/p&gt;
&lt;p&gt;The Cider drop of our dll is the one that has all the new code and should be better behaved.&lt;/p&gt;
&lt;p&gt;We chose to live with this situation, because of several reasons.&amp;nbsp; We didn't want to remove our stuff from the product all together for the Feb CTP release...that would just be rude!&amp;nbsp; And we didn't want you to have to deal with old out of date and broken code either...so we compromised. &lt;/p&gt;
&lt;p&gt;I promise we'll get all of this ironed out soon.!&lt;/p&gt;
&lt;p&gt;Peace, Love and Crossbow!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=522723" width="1" height="1"&gt;</description></item><item><title>Crossbow on Dr. Dobbs</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/01/09/510842.aspx</link><pubDate>Mon, 09 Jan 2006 20:26:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:510842</guid><dc:creator>mhender</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/510842.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=510842</wfw:commentRss><description>&lt;P&gt;I recently did an interview with Scott Swiggart on the subject of Crossbow and the article ended up on Dr. Dobbs, check it out: &lt;A href="http://www.ddj.com/documents/s=9776/ddj1134151231499/swigart3.htm"&gt;http://www.ddj.com/documents/s=9776/ddj1134151231499/swigart3.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I also did an MSDN TV segment, but it's not posted yet, but keep an eye out for it (&lt;A href="http://msdn.microsoft.com/msdntv"&gt;http://msdn.microsoft.com/msdntv&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=510842" width="1" height="1"&gt;</description></item><item><title>Okay, I'm a Deadbeat Blogger!</title><link>http://blogs.msdn.com/mhendersblog/archive/2006/01/03/508994.aspx</link><pubDate>Wed, 04 Jan 2006 02:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:508994</guid><dc:creator>mhender</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/508994.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=508994</wfw:commentRss><description>&lt;P&gt;Yikes, you mean the last time I posted something on my blog was on Halloween?&amp;nbsp; Geez, I'm really sorry about that and I'll try to make it up to you...really I will.&amp;nbsp; You see, there's a few reasons why I've been delinquent in blogland lately...&amp;nbsp; One reason is that I just got too excited and posted too frequently and used up all my good material and then I really didn't have anything interesting to say.&amp;nbsp; The other reason is simply just being busy with stuff...then there's the holidays...you know how it goes.&amp;nbsp; But I'm back and I'll do my best to provide some useful content.&lt;/P&gt;
&lt;P&gt;I'm already getting some ideas so stay tuned...&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=508994" width="1" height="1"&gt;</description></item><item><title>Hosting Windows Forms and ActiveX Controls on a Canvas</title><link>http://blogs.msdn.com/mhendersblog/archive/2005/10/31/487362.aspx</link><pubDate>Mon, 31 Oct 2005 20:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:487362</guid><dc:creator>mhender</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mhendersblog/comments/487362.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mhendersblog/commentrss.aspx?PostID=487362</wfw:commentRss><description>&lt;DIV id=NowPlaying&gt;
&lt;DIV id=Intro&gt;I'm blogging to:&lt;/DIV&gt;
&lt;DIV id=Image&gt;&lt;A title="Check out KEXP" href="http://www.kexp.org/"&gt;&lt;IMG src="http://www.windowsforms.net/blogs/mhendersblog/kexp_logo.jpg"&gt;&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id=Artist&gt;
&lt;H5&gt;KEXP&lt;/H5&gt;&lt;/DIV&gt;
&lt;DIV id=Album&gt;
&lt;H5&gt;Live Stream&lt;/H5&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;IMG src="http://www.windowsforms.net/blogs/mhendersblog/Oct31Post/f3.jpg"&gt; 
&lt;H1&gt;Happy Halloween! &lt;/H1&gt;
&lt;P&gt;&lt;FONT size=2&gt;I received an email from Keeron today and he was experiencing some difficulties in hosting an ActiveX control in a WindowsFormsHost which was parented to a Canvas in a WPF application.&amp;nbsp; His basic problem seemed to be that the control simply was not showing up in the WPF application at all.&amp;nbsp; So what's up with that? &lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;Let's start off by removing the ActiveX control from the equation since the issue isn't directly related to the ActiveX control, the issue exists for just standard Windows Forms controls as well.&amp;nbsp; So let's assume we have a simply scenario where we want to host a Windows Forms button in a WPF application.&amp;nbsp; Let's first consider hosting it in a Grid element then we will switch it to use a Canvas element.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#800000&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;AvalonApplication27.Window1&lt;/FONT&gt;"&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;A href="http://schemas.microsoft.com/winfx/avalon/2005"&gt;http://schemas.microsoft.com/winfx/avalon/2005&lt;/A&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;A href="http://schemas.microsoft.com/winfx/xaml/2005"&gt;http://schemas.microsoft.com/winfx/xaml/2005&lt;/A&gt;&lt;/FONT&gt;&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Title&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;AvalonApplication27&lt;/FONT&gt;"&lt;BR&gt;&lt;FONT color=#ff0000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loaded&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;WindowLoaded&lt;/FONT&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Grid&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;x:Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;grid1&lt;/FONT&gt;"&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Grid&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;The code behind would look something like:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; WindowLoaded(&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt; sender, &lt;FONT color=#008080&gt;RoutedEventArgs&lt;/FONT&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsFormsHost&lt;/FONT&gt; host = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;WindowsFormsHost&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt; b = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.Text = &lt;FONT color=#800000&gt;"WF Button"&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Children.Add(b);&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;.grid1.Children.Add(host);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Run the app and everything works just fine.&amp;nbsp; But now lets change the Grid element to a Canvas element...&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Class&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AvalonApplication27.Window1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;A href="http://schemas.microsoft.com/winfx/avalon/2005"&gt;http://schemas.microsoft.com/winfx/avalon/2005&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:x&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;A href="http://schemas.microsoft.com/winfx/xaml/2005"&gt;http://schemas.microsoft.com/winfx/xaml/2005&lt;/A&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Title&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;AvalonApplication27&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loaded&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;WindowLoaded&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Canvas&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000 size=2&gt;x:Name&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;=&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;canvas1&lt;/FONT&gt;&lt;FONT size=2&gt;"&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Canvas&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;Window&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;And change the code behind to reference the Canvas instead of the Grid:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; WindowLoaded(&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt; sender, &lt;FONT color=#008080&gt;RoutedEventArgs&lt;/FONT&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsFormsHost&lt;/FONT&gt; host = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;WindowsFormsHost&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt; b = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.Text = &lt;FONT color=#800000&gt;"WF Button"&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Children.Add(b);&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;.canvas1.Children.Add(host);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Run the app again and we don't see our button!&amp;nbsp; What gives?&amp;nbsp; Well, let's think about it just a second.&amp;nbsp; Firstly, I neglected to indicate where in the canvas the button should go.&amp;nbsp; Normally, you would do this is XAML as follows:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#0000ff&gt;
&lt;P&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#800000&gt;Canvas&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;x:Name&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;canvas1&lt;/FONT&gt;"&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/FONT&gt;&lt;FONT color=#800000&gt;Button&lt;/FONT&gt;&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Canvas.Top&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;5&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt; &lt;/FONT&gt;&lt;FONT color=#ff0000&gt;Canvas.Left&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;=&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;5&lt;/FONT&gt;"&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/FONT&gt;I'm a button&lt;FONT color=#0000ff&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Button&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;BR&gt;&amp;lt;/&lt;/FONT&gt;&lt;FONT color=#800000&gt;Canvas&lt;/FONT&gt;&lt;FONT color=#0000ff&gt;&amp;gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT size=2&gt;But I'm working in code so I need to figure out how to do this using C#...&amp;nbsp;&amp;nbsp; Well the Canvas.Top and Canvas.Left properties are actually "attached properties" in WPF parlance and to set these using code you would use the SetValue() method on the object in question and then provide the property and value:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; WindowLoaded(&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt; sender, &lt;FONT color=#008080&gt;RoutedEventArgs&lt;/FONT&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsFormsHost&lt;/FONT&gt; host = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;WindowsFormsHost&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt; b = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.Text = &lt;FONT color=#800000&gt;"WF Button"&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Children.Add(b);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.SetValue(&lt;FONT color=#008080&gt;Canvas&lt;/FONT&gt;.TopProperty, 5.0);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.SetValue(&lt;FONT color=#008080&gt;Canvas&lt;/FONT&gt;.LeftProperty, 5.0);&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;.canvas1.Children.Add(host);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Cool, that should do it right?&amp;nbsp; Let's give it a whirl...&amp;nbsp; Doh!&amp;nbsp; Still didn't work!&amp;nbsp; Why not?&amp;nbsp; Well, the issue is related to how the WPF layout engine works.&amp;nbsp; The problem is that since we did not explicitly set the size of the WindowsFormsHost control, the layout engine thinks that it has a size of 0 and therefore does not layout the control properly.&amp;nbsp; To fix this, we just need to give the WindowsFormsHost control an explicit size:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#0000ff&gt;private&lt;/FONT&gt; &lt;FONT color=#0000ff&gt;void&lt;/FONT&gt; WindowLoaded(&lt;FONT color=#0000ff&gt;object&lt;/FONT&gt; sender, &lt;FONT color=#008080&gt;RoutedEventArgs&lt;/FONT&gt; e)&lt;BR&gt;{&lt;BR&gt;&lt;FONT color=#008080&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WindowsFormsHost&lt;/FONT&gt; host = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; &lt;FONT color=#008080&gt;WindowsFormsHost&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Height = 100;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Width = 300;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt; b = &lt;FONT color=#0000ff&gt;new&lt;/FONT&gt; System.Windows.Forms.&lt;FONT color=#008080&gt;Button&lt;/FONT&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.Text = &lt;FONT color=#800000&gt;"WF Button"&lt;/FONT&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Children.Add(b);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.SetValue(&lt;FONT color=#008080&gt;Canvas&lt;/FONT&gt;.TopProperty, 5.0);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.SetValue(&lt;FONT color=#008080&gt;Canvas&lt;/FONT&gt;.LeftProperty, 5.0);&lt;BR&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this&lt;/FONT&gt;.canvas1.Children.Add(host);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Now when we re-run the application, we will see our button.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=487362" width="1" height="1"&gt;</description></item></channel></rss>