<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Ning Zhang's Blog</title>
	
	<link>http://www.ningzhang.org</link>
	<description>About Silverlight, Microsoft technologies, and software development in general.</description>
	<lastBuildDate>Thu, 22 Oct 2009 14:27:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/NingZhangsBlog" type="application/rss+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Silverlight Design Time: Toolkit October 2009 Release Update</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/da2jr16qkxQ/</link>
		<comments>http://www.ningzhang.org/2009/10/21/silverlight-design-time-toolkit-october-2009-release-update/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 01:18:20 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Visual Studio 2010]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/10/21/silverlight-design-time-toolkit-october-2009-release-update/</guid>
		<description>Overview
Visual Studio 2010 Beta 2 is available now. For Silverlight developers, the most exciting news about VS2010 is that Silverlight designer will be in feature parity with WPF designer, and VS2010 will support multi-targeting for Silverlight development. Silverlight Toolkit team has been working closely with Cider team in providing the design time experience for Silverlight [...]</description>
			<content:encoded><![CDATA[<h3>Overview</h3>
<p><a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" target="_blank">Visual Studio 2010 Beta 2</a> is available now. For Silverlight developers, the most exciting news about VS2010 is that Silverlight designer will be in feature parity with WPF designer, and VS2010 will support multi-targeting for Silverlight development. Silverlight Toolkit team has been working closely with Cider team in providing the design time experience for Silverlight SDK and Toolkit controls. The design time for Silverlight 3 SDK controls has been released with <a href="http://www.microsoft.com/downloads/details.aspx?familyid=1EA49236-0DE7-41B1-81C8-A126FF39975B&amp;displaylang=en" target="_blank">SL3 SDK</a> in August 2009, and is also chain installed by VS2010 Beta2. The design time for Toolkit controls, together with sources for both SDK and Toolkit controls, and their design time, samples, unit tests etc, are in <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a>&#160;<a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514" target="_blank">October 2009 Release</a>. We purposely made October 2009 release to be in sync with Visual Studio 2010 Beta 2 on Monday, 10/19/2009. This post demonstrates the new design time experiences for Silverlight controls in VS2010.&#160; </p>
<h3>Install</h3>
<p>VS2010 installs side by side with VS2008. Multiple releases of Toolkit install side by side too. So it is perfectly safe to install VS2010 and Toolkit October 2009 release on your main machine. The only caveat is that if you have a pre August 2009 version of Silverlight 3 SDK installed, you will need to uninstall it first, before installing VS2010. You can install VS2010 Beta2 from <a title="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx">http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx</a>, and Silverlight Toolkit from <a href="http://silverlight.codeplex.com">http://silverlight.codeplex.com</a>. </p>
<h3>Walkthrough</h3>
<p>The October 2009 release is for Silverlight 3 only. It provides design time support for both VS2008 and VS2010, as well as Blend 3. Below walkthrough will be VS2010 only. Design time experience for VS2008 and Blend 3 are similar to <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24246" target="_blank">July 2009 release</a>. Please see my previous posts for design time experience with VS2008 and Blend3.</p>
<ul>
<li>Create a new Silverlight Application project in VS2010, notice that:      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3New2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Create New Silverlight Application Project" border="0" alt="Create New Silverlight Application Project" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3New_thumb2.png" width="584" height="407" /></a>
<ul>
<li>the toolbox is populated with both SDK and Toolkit controls, with nice icons. If you have Blend3 installed before Toolkit, you may see a lot of Blend controls on the toolbox that are not supposed to. You can safely remove them by right click a control in the toolbox and select delete. </li>
<li>it is a real designer: both the design view and the properties window work! </li>
</ul>
</li>
<li>double click TabControl in the toolbox will add a tabControl1. Notice that:     <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabCtrlInit2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Add Tab Control from Toolbox" border="0" alt="Add Tab Control from Toolbox" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabCtrlInit_thumb2.png" width="584" height="404" /></a>
<ul>
<li>A reference to System.Windows.Controls.dll is added, together with a <font face="Lucida Console">xmlns definition: xmlns:controls=&quot;clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls&quot;</font> </li>
<li>tabControl1 is initialized with a tabItem1, which itself is initialized with a header and &lt;Grid/&gt; content. (via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.defaultinitializer.aspx" target="_blank">DefaultInitializer</a>) </li>
<li>Property Items is selected in the Properties window (via <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultpropertyattribute.aspx" target="_blank">DefaultPropertyAttribute</a>) </li>
<li>Properties are categorized (via <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.categoryattribute.aspx" target="_blank">CategoryAttribute</a>), and have tooltip (via <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx" target="_blank">DescriptionAttribute</a>) </li>
</ul>
</li>
<li>Double click tabControl1 will add an event handler for SelectionChanged event (via <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.defaulteventattribute.aspx" target="_blank">DefaultEventAttribute</a>)      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabDefEvent2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Default Event" border="0" alt="Default Event" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabDefEvent_thumb2.png" width="584" height="404" /></a> </li>
<li>right click tabControl1, select Add Tab (via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.interaction.primaryselectioncontextmenuprovider.aspx" target="_blank">PrimarySelectionContextMenuProvider</a>):      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabAddTabCM2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3TabAddTabCM" border="0" alt="VS10SL3TabAddTabCM" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabAddTabCM_thumb1.png" width="584" height="404" /></a> </li>
<li>A new tabItem2 is added. Notice that:      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabAddTabResult1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3TabAddTabResult" border="0" alt="VS10SL3TabAddTabResult" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabAddTabResult_thumb1.png" width="584" height="405" /></a>
<ul>
<li>tabItem2 is initialized with a &lt;Grid/&gt; content </li>
<li>tabItem2’s default property Header is highlighted. You can type into the text box next to it and change the object typed Header property directly. (via <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverterattribute.aspx" target="_blank">TypeConverterAttribute</a>) </li>
<li>all properties have nice infotip </li>
</ul>
</li>
<li>double click DatePicker on toolbox:      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3DatePickerAdd1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3DatePickerAdd" border="0" alt="VS10SL3DatePickerAdd" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3DatePickerAdd_thumb1.png" width="584" height="404" /></a>
<ul>
<li>a datePicker1 is added to tabItem2’s &lt;Grid&gt; (via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.interaction.parentadapter.aspx" target="_blank">ParentAdapter</a>) </li>
<li>datePicker1 is fully expanded, even though its IsDropDownOpen property is false (via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.designmodevalueprovider.aspx" target="_blank">DesignModeValueProvider</a>) </li>
</ul>
</li>
<li>Now click tabItem1, notice that tabItem2’s content is hidden and tabItem1’s is shown:     <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabItemSelect1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3TabItemSelect" border="0" alt="VS10SL3TabItemSelect" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabItemSelect_thumb1.png" width="584" height="404" /></a> </li>
<li>click Chart on toolbox:      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabAddChartpng1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3TabAddChartpng" border="0" alt="VS10SL3TabAddChartpng" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3TabAddChartpng_thumb1.png" width="584" height="408" /></a>
<ul>
<li>a chart1 is added to the right place, initialized with sample data, and nicely rendered </li>
<li>default property Series is selected in the properties window </li>
</ul>
</li>
<li>click the … button next to Series property to pop up the Collection Editor:     <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3ChartSeries1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3ChartSeries" border="0" alt="VS10SL3ChartSeries" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3ChartSeries_thumb1.png" width="584" height="353" /></a>
<ul>
<li>the Select item combobox is populated with the correct types (via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.newitemtypesattribute.aspx" target="_blank">NewItemTypesAttribute</a>). The pink background for the icons are fixed now. </li>
<li>the Properties window for the series highlights the default property DependentValuePath, have all properties categorized (like the Data Visualization category), and you can modify the object typed Title property directly in the text box. </li>
</ul>
</li>
<li>Create a simple data class with some simple properties, and add it as a data source, via Data |&#160; Show Data Sources menu item:&#160; <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3Binding11.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3Binding1" border="0" alt="VS10SL3Binding1" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3Binding1_thumb1.png" width="584" height="396" /></a> </li>
<li>Drag MyData over tabItem1’s header and drop it :      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3Binding21.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Data Binding" border="0" alt="Data Binding" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3Binding2_thumb1.png" width="584" height="398" /></a>
<ul>
<li>a CollectionViewDataSource is inserted, used as <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.datacontext.aspx" target="_blank">DataContext</a> of the LayoutRoot, and tabItem1’s Header is bound to it. (Via <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultbindingpropertyattribute.aspx" target="_blank">DefaultBindingPropertyAttribute</a>) </li>
</ul>
</li>
<li>Just for fun, open the project in Blend 3, you will see very similar design time behaviors:     <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3Blend31.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS10SL3Blend3" border="0" alt="VS10SL3Blend3" src="http://www.ningzhang.org/wp-content/uploads/2009/10/VS10SL3Blend3_thumb1.png" width="584" height="439" /></a> </li>
</ul>
<h3>Conclusion</h3>
<p>Above walkthrough is only a peek into all the design time features we have implemented for VS2010. I am very excited that VS2010 now provides a real designer for Silverlight, and I will continue enriching the design time experience for Silverlight in VS and Blend. Your feedback is welcome. </p>
<p>I will write a series of posts explaining how those design time experience are implemented. </p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:bfdefe3f-2272-4482-92ff-7ca1607220e9" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight+Toolkit" rel="tag">Silverlight Toolkit</a>,<a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Design+Time" rel="tag">Design Time</a>,<a href="http://technorati.com/tags/Visual+Studio+2010" rel="tag">Visual Studio 2010</a>,<a href="http://technorati.com/tags/Visual+Studio" rel="tag">Visual Studio</a></div>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update&amp;notes=Overview%20%20Visual%20Studio%202010%20Beta%202%20is%20available%20now.%20For%20Silverlight%20developers%2C%20the%20most%20exciting%20news%20about%20VS2010%20is%20that%20Silverlight%20designer%20will%20be%20in%20feature%20parity%20with%20WPF%20designer%2C%20and%20VS2010%20will%20support%20multi-targeting%20for%20Silverlight%20de" title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=Overview%20%20Visual%20Studio%202010%20Beta%202%20is%20available%20now.%20For%20Silverlight%20developers%2C%20the%20most%20exciting%20news%20about%20VS2010%20is%20that%20Silverlight%20designer%20will%20be%20in%20feature%20parity%20with%20WPF%20designer%2C%20and%20VS2010%20will%20support%20multi-targeting%20for%20Silverlight%20de" title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;t=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update&amp;annotation=Overview%20%20Visual%20Studio%202010%20Beta%202%20is%20available%20now.%20For%20Silverlight%20developers%2C%20the%20most%20exciting%20news%20about%20VS2010%20is%20that%20Silverlight%20designer%20will%20be%20in%20feature%20parity%20with%20WPF%20designer%2C%20and%20VS2010%20will%20support%20multi-targeting%20for%20Silverlight%20de" title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;t=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update&opener=bm&amp;ei=UTF-8&amp;d=Overview%20%20Visual%20Studio%202010%20Beta%202%20is%20available%20now.%20For%20Silverlight%20developers%2C%20the%20most%20exciting%20news%20about%20VS2010%20is%20that%20Silverlight%20designer%20will%20be%20in%20feature%20parity%20with%20WPF%20designer%2C%20and%20VS2010%20will%20support%20multi-targeting%20for%20Silverlight%20de" title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;t=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F10%2F21%2Fsilverlight-design-time-toolkit-october-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20October%202009%20Release%20Update&amp;bodytext=Overview%20%20Visual%20Studio%202010%20Beta%202%20is%20available%20now.%20For%20Silverlight%20developers%2C%20the%20most%20exciting%20news%20about%20VS2010%20is%20that%20Silverlight%20designer%20will%20be%20in%20feature%20parity%20with%20WPF%20designer%2C%20and%20VS2010%20will%20support%20multi-targeting%20for%20Silverlight%20de" title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/da2jr16qkxQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/10/21/silverlight-design-time-toolkit-october-2009-release-update/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/10/21/silverlight-design-time-toolkit-october-2009-release-update/</feedburner:origLink></item>
		<item>
		<title>Silverlight Design Time: Toolkit July 2009 Release Update</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/ir8tNHY0Sxo/</link>
		<comments>http://www.ningzhang.org/2009/09/29/silverlight-design-time-toolkit-july-2009-release-update/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 22:38:19 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Silverlight 3]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/09/29/silverlight-design-time-toolkit-july-2009-release-update/</guid>
		<description>I have been very busy and haven’t post for a while, so this is a quick late post on Toolkit July 2009 Release. This release is the last Toolkit release for Silverlight 2: when a new version of Silverlight RTMs, we drop support for the previous version, so each Toolkit release needs to support at [...]</description>
			<content:encoded><![CDATA[<p>I have been very busy and haven’t post for a while, so this is a quick late post on Toolkit <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24246" target="_blank">July 2009 Release</a>. This release is the last Toolkit release for Silverlight 2: when a new version of Silverlight RTMs, we drop support for the previous version, so each Toolkit release needs to support at most two versions of Silverlight. As for design time feature updates, there have been a lot of improvements over <a href="http://www.ningzhang.org/2009/03/19/silverlight-toolkit-design-time-features-march-2009-release-update/" target="_blank">March 2009 Release</a>. I will use a simple walkthrough to highlight a few noticeable new features: </p>
<ul>
<li>Install Silverlight 3, Blend 3 and Toolkit from <a href="http://silverlight.net/getstarted/">http://silverlight.net/getstarted/</a> </li>
<li>Open Blend 3, create a new Silverlight 3 Application project </li>
<li>Open Asset Library, notice few improvements:
<ul>
<li>the new Asset Library. See Unni’s blog <a href="http://blogs.msdn.com/unnir/archive/2009/05/22/the-blend-3-asset-library.aspx" target="_blank">The Blend 3 Asset Library</a> for more info.&#160; </li>
<li>the nicer icons and more informative infotip </li>
</ul>
</li>
</ul>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/09/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blend 3 Asset Library" border="0" alt="Blend 3 Asset Library" src="http://www.ningzhang.org/wp-content/uploads/2009/09/image_thumb.png" width="604" height="388" /></a> </p>
<ul>
<li>Add an Expander control, and set it as the new active container: </li>
</ul>
<p> <a href="http://www.ningzhang.org/wp-content/uploads/2009/09/image1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Pin Active Container " border="0" alt="Pin Active Container " src="http://www.ningzhang.org/wp-content/uploads/2009/09/image_thumb1.png" width="604" height="398" /></a>
<ul>
<li>Add a DatePicker to the Expander, notice that both the DatePicker and its Calendar drop down are shown, even though both Expander’s IsExpanded and DatePicker’s IsDropDownOpen are false. </li>
</ul>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/09/image2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2009/09/image_thumb2.png" width="604" height="389" /></a> </p>
<ul>
<li>Select LayoutRoot so Expander and the nest DatePicker are no longer selected, notice that both are now collapsed. </li>
</ul>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/09/image3.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2009/09/image_thumb3.png" width="604" height="389" /></a> </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/09/image4.png" target="_blank"><img style="border-right-width: 0px; margin: 0px 0px 0px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Toolbox" border="0" alt="Visual Studio Toolbox" align="right" src="http://www.ningzhang.org/wp-content/uploads/2009/09/image_thumb4.png" width="206" height="663" /></a>Open the project in Visual Studio,notice that the Toolbox is populated with lots of controls from Silverlight SDK and Toolkit, with nice icons. </p>
<p>&#160;</p>
<p>So far, design time features for Silverlight are mostly exposed through Blend. This will change with next beta of Visual Studio 2010, which will come out soon, according to this Visual Studio Magazine <a href="http://visualstudiomagazine.com/Blogs/RDN-Express/2009/09/VS2010-and-.NET-4-Beta-2-Expected-Soon.aspx" target="_blank">article</a>. Stay tuned!</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update&amp;notes=I%20have%20been%20very%20busy%20and%20haven%E2%80%99t%20post%20for%20a%20while%2C%20so%20this%20is%20a%20quick%20late%20post%20on%20Toolkit%20July%202009%20Release.%20This%20release%20is%20the%20last%20Toolkit%20release%20for%20Silverlight%202%3A%20when%20a%20new%20version%20of%20Silverlight%20RTMs%2C%20we%20drop%20support%20for%20the%20previous%20vers" title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=I%20have%20been%20very%20busy%20and%20haven%E2%80%99t%20post%20for%20a%20while%2C%20so%20this%20is%20a%20quick%20late%20post%20on%20Toolkit%20July%202009%20Release.%20This%20release%20is%20the%20last%20Toolkit%20release%20for%20Silverlight%202%3A%20when%20a%20new%20version%20of%20Silverlight%20RTMs%2C%20we%20drop%20support%20for%20the%20previous%20vers" title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;t=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update&amp;annotation=I%20have%20been%20very%20busy%20and%20haven%E2%80%99t%20post%20for%20a%20while%2C%20so%20this%20is%20a%20quick%20late%20post%20on%20Toolkit%20July%202009%20Release.%20This%20release%20is%20the%20last%20Toolkit%20release%20for%20Silverlight%202%3A%20when%20a%20new%20version%20of%20Silverlight%20RTMs%2C%20we%20drop%20support%20for%20the%20previous%20vers" title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;t=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update&opener=bm&amp;ei=UTF-8&amp;d=I%20have%20been%20very%20busy%20and%20haven%E2%80%99t%20post%20for%20a%20while%2C%20so%20this%20is%20a%20quick%20late%20post%20on%20Toolkit%20July%202009%20Release.%20This%20release%20is%20the%20last%20Toolkit%20release%20for%20Silverlight%202%3A%20when%20a%20new%20version%20of%20Silverlight%20RTMs%2C%20we%20drop%20support%20for%20the%20previous%20vers" title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;t=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F09%2F29%2Fsilverlight-design-time-toolkit-july-2009-release-update%2F&amp;title=Silverlight%20Design%20Time%3A%20Toolkit%20July%202009%20Release%20Update&amp;bodytext=I%20have%20been%20very%20busy%20and%20haven%E2%80%99t%20post%20for%20a%20while%2C%20so%20this%20is%20a%20quick%20late%20post%20on%20Toolkit%20July%202009%20Release.%20This%20release%20is%20the%20last%20Toolkit%20release%20for%20Silverlight%202%3A%20when%20a%20new%20version%20of%20Silverlight%20RTMs%2C%20we%20drop%20support%20for%20the%20previous%20vers" title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/ir8tNHY0Sxo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/09/29/silverlight-design-time-toolkit-july-2009-release-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/09/29/silverlight-design-time-toolkit-july-2009-release-update/</feedburner:origLink></item>
		<item>
		<title>Editing Model &amp; Default Initializer for Silverlight Controls</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/44AOjbTmESE/</link>
		<comments>http://www.ningzhang.org/2009/05/11/editing-model-default-initializer-for-silverlight-controls/#comments</comments>
		<pubDate>Mon, 11 May 2009 09:43:00 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[DefaultInitializer]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/05/11/editing-model-default-initializer-for-silverlight-controls/</guid>
		<description>This is part of the series on design time feature implementation in Silverlight Toolkit. This post uses the Chart default initializer to illustrate how to implement default initializer for Silverlight controls, and explain the underlying editing model architecture.</description>
			<content:encoded><![CDATA[<p>
<link rel="stylesheet" type="text/css" href="http://www.ningzhang.org/codesnippet.css" />
</p>
<h3>Introduction</h3>
<p>This is part of the series on design time feature implementation in <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a>. This post uses the Chart default initializer to illustrate how to implement default initializer for Silverlight controls, and explain the underlying editing model architecture.</p>
<h3>Experience</h3>
<p>If you install <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430#DownloadId=62369" target="_blank">Silverlight 3 Toolkit</a> in <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>, you can drag the Chart control from Blend Asset Library and drop it onto designer surface, and you have a chart nicely initialized and rendered:</p>
<p><a href="http://www.ningzhang.org/2009/03/19/silverlight-toolkit-design-time-features-march-2009-release-update/" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Chart default initializer" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image26.png" alt="Chart default initializer" width="604" height="350" /></a></p>
<p>You can read more about it in prior post <a href="http://www.ningzhang.org/2009/03/19/silverlight-toolkit-design-time-features-march-2009-release-update/" target="_blank">Silverlight Toolkit Design Time Features: March 2009 Release Update</a>.</p>
<h3>Architecture</h3>
<h4>DefaultInitializer</h4>
<p>It is actually pretty simple to provide a default initializer for a Silverlight control:</p>
<ul>
<li>implement a subclass of <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.defaultinitializer.aspx" target="_blank">DefaultInitializer</a>, and override its <a href="http://msdn.microsoft.com/en-us/library/bb532681.aspx" target="_blank">InitializeDefaults</a> function</li>
<li>associate the default initializer class with the control class via a <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.features.featureattribute.aspx" target="_blank">FeatureAttribute</a></li>
</ul>
<p>Below screenshot shows the implementation of DefaultInitializer abstract base class, and other classes in Microsoft.Windows.Design.Model namespace that will be discussed shortly:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image12.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="DefaultInitializer" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb8.png" border="0" alt="DefaultInitializer" width="604" height="454" /></a></p>
<p>Initialization is done in InitializeDefaults override, and result is serialized into xaml. So the first step in implementing a default initializer is to define the desired xaml to be produced.</p>
<h4>Editing Model</h4>
<p>Once the result xaml is defined, I wish there is a higher level abstraction/method that would just take the xaml. But unfortunately we have to use a much lower level (thus more flexible and powerful) imperative API called editing model that consists of classes like <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelitem.aspx" target="_blank">ModelItem</a>, <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelproperty.aspx" target="_blank">ModelProperty</a>, <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelevent.aspx" target="_blank">ModelEvent</a>, <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelfactory.aspx" target="_blank">ModelFactory</a> and <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.services.modelservice.aspx" target="_blank">ModelService</a>. The MSDN page <a href="http://msdn.microsoft.com/en-us/library/bb514661.aspx" target="_blank">Editing Model Architecture</a> gives an basic overview:</p>
<blockquote><p>Your design-time implementation interacts with run-time controls though a programming interface called the editing model. The objects being designed are called editable objects.</p>
<p>Your controls are defined in Extensible Application Markup Language (XAML). You update the XAML for your controls programmatically by using the editing model.</p>
<p><img src="http://i.msdn.microsoft.com/Global/Images/clear.gif" alt="" /><strong>Model, Wrapper, and View</strong></p>
<p><a></a></p>
<p>The editing model consists of three functional subunits: a model, a public wrapper that abstracts the model, and a view that represents the user interface (UI) of the model. The model and the view are separate, but the wrapper and model are closely related. The following illustration shows the relationship among the three subunits.</p>
<p><img src="http://i.msdn.microsoft.com/Bb514661.Cider_ModWrap(en-us,VS.90).png" alt="Model, ModelItem, and View relationships" /></p>
<p>The design environment uses the <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelitem.aspx">ModelItem</a> type to communicate with the underlying model. All changes are made to the <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelitem.aspx">ModelItem</a> wrappers, which affect the underlying model. This allows the model to be simple. The <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.model.modelitem.aspx">ModelItem</a> wrappers handle complex designer features, such as transaction support, undo tracking, and change notifications.</p></blockquote>
<p>Below class diagram may help explain interactions among core classes of the editing model:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image13.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Editing Model Class Diagram" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb9.png" border="0" alt="Editing Model Class Diagram" width="604" height="442" /></a></p>
<p>Use below xaml as an example:</p>
<p>
<div id="codeSnippetWrapper">
<pre id="codeSnippet" class="csharpcode"><span class="kwrd">&lt;</span><span class="html">UserControl</span>
    <span class="attr">xmlns</span><span class="kwrd">="http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
    <span class="attr">xmlns:x</span><span class="kwrd">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
    <span class="attr">x:Class</span><span class="kwrd">="ModelTest.Page"</span> <span class="attr">Width</span><span class="kwrd">="640"</span> <span class="attr">Height</span><span class="kwrd">="480"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Grid</span> <span class="attr">x:Name</span><span class="kwrd">="LayoutRoot"</span> <span class="attr">Background</span><span class="kwrd">="White"</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Button</span> <span class="attr">x:Name</span><span class="kwrd">="Button"</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Rectangle</span> <span class="attr">x:Name</span><span class="kwrd">="Rectangle"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Button</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">UserControl</span><span class="kwrd">&gt;</span></pre>
</div>
</p>
<ul>
<li>ModelItem: assume variable <em>item </em>is the ModelItem for the Button control above,
<ul>
<li>Name is persisted as <em>x:Name</em> attribute in xaml: <em>item.Name = “Button” </em>is persisted in xaml as <em>x:Name = “Button”</em>.</li>
<li>ItemType is the Type object of the underlying control, and decides the tag used in xaml:<em> item.PropertyType == tyepof(Button)</em>, and the xaml tag is <em>&lt;Button /&gt;</em>.</li>
<li>Properties is the collection of properties, wrapped in ModelProperty type, of the underlying control. For example: <em>item[“ClickMode”] = ClickMode.Release </em>will be persisted in xaml as <em>ClickMode=&#8221;Release&#8221;</em>.</li>
<li>Content represents the Content property defined in ContentControl (and inherited by its subclasses): <em>item.Content </em>is the ModelItem representing the Rectangle object.</li>
<li>Source: when a ModelItem represents an element that’s a property of another element, Source is the ModelProperty wrapper of that property. For example, <em>item.Content.Value.Source == item.Content // the Rectangle</em>.</li>
<li>Events represents the collection of events of the underlying control, wrapped in ModelEvent type. From my debugging experience, it is always null, so it seems Events property is not yet supported by Blend3 for Silverlight3 yet.</li>
<li>Parent is the the logic parent of the underlying control, wrapped in ModelItem type. ex: item.Parent is the ModelItem for Grid.</li>
<li>Root is the ModelItem wrapper for root visual, ex: item.Root represents the UserControl.</li>
</ul>
</li>
<li>ModelProperty: assume variable <em>prop</em> is the ModelProperty for Button.Content, i.e. <em>prop = item.Content</em>,
<ul>
<li>Name is the name of the property of the underlying control. It is persisted in xaml as attribute name. ex: <em>prop.Name == “Content”</em>.</li>
<li>PropertyType is the Type object of the property of the underlying control this ModelProperty object represents. ex: <em>prop.PropertyType = typeof(object)</em>.</li>
<li>AttachedOwnerType is the Type object of the control that first defines the property this ModelProperty object represents. ex: <em>prop.AttachedOwnerType == typeof(ContentControl) // note: not Button.</em></li>
<li>Value is the value of the property of the underlying control, wrapped in ModelItem type. ex: prop.Value is the ModelItem representing the Rectangle object.</li>
<li>Parent is the control, wrapped in ModelItem type, of which the property belongs to. ex: <em>prop.Parent == item</em>.</li>
</ul>
</li>
<li>ModelEvent: as mentioned above, item.Events is always null, so it doesn’t seem that ModelEvent is supported in Blend3 for Silverlight3 yet. But assume it works, and variable evt is the ModelEvent for Button.Click, i.e., <em>evt = item.Events[“Click”]</em>,
<ul>
<li>Name is the name of the event. ex: evt.Name == “Click”.</li>
<li>EventType is the type of the event delegate, ex: <em>evt.EventType == typeof(RoutedEventHandler)</em>.</li>
<li>Handlers is the string collection of event handlers, ex: <em>evt.Handlers = new string[] { “Button_Click” }</em> will be persisted as <em>Click = “Button_Click”</em>. Note: this is pure speculation, since ModelEvent isn’t yet supported, and I don’t know whether/when/how it will be supported for Silverlight.</li>
<li>Parent is the control, wrapped in ModelItem type, of which this event belongs to. ex: <em>evt.Parent == item</em>.</li>
</ul>
</li>
</ul>
<h3>Implementation</h3>
<p>The Chart default initializer class ChartDefaultInitializer is implemented in ChartDefaultInitializer.cs, and registered in ChartMetadata.cs. Both files are in Controls.DataVisualization.Toolkit.Design.csproj of Silverlight.Controls.Design.sln. Please read prior post <a href="http://www.ningzhang.org/2008/12/28/design-time-feature-implementation-in-silverlight-toolkit/" target="_blank">Design Time Feature Implementation in Silverlight Toolkit</a> for more information.</p>
<h4>Result XAML</h4>
<p>As the first step, define the result xaml to be produced by ChartDefaultInitializer:</p>
<p>
<div id="codeSnippetWrapper">
<pre id="codeSnippet" class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Charting:Chart</span> <span class="attr">Title</span><span class="kwrd">="Chart Title"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Charting:Chart.DataContext</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">PointCollection</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Point</span> <span class="attr">X</span><span class="kwrd">="1"</span> <span class="attr">Y</span><span class="kwrd">="10"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Point</span> <span class="attr">X</span><span class="kwrd">="2"</span> <span class="attr">Y</span><span class="kwrd">="20"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Point</span> <span class="attr">X</span><span class="kwrd">="3"</span> <span class="attr">Y</span><span class="kwrd">="30"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Point</span> <span class="attr">X</span><span class="kwrd">="4"</span> <span class="attr">Y</span><span class="kwrd">="40"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">PointCollection</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Charting:Chart.Series</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">Charting:ColumnSeries</span> <span class="attr">ItemsSource</span><span class="kwrd">="{Binding}"</span>
                <span class="attr">DependentValuePath</span><span class="kwrd">="X"</span>
                <span class="attr">IndependentValuePath</span><span class="kwrd">="Y"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Charting:Chart.Series</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Charting:Chart.DataContext</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">Charting:Chart</span><span class="kwrd">&gt;</span></pre>
 </div>
</p>
<h4>Registration</h4>
<p>Done in ChartMetadata.cs with following code:</p>
<div>
<pre id="codeSnippet" class="csharpcode">b.AddCustomAttributes(<span class="kwrd">new</span> FeatureAttribute(<span class="kwrd">typeof</span>(ChartDefaultInitializer)));</pre>
</div>
<h4>References</h4>
<p>See below screenshot:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image14.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="References" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb10.png" border="0" alt="References" width="544" height="454" /></a></p>
<p>Even though DefaultInitializer is defined in version 3.5 of Microsoft.Windows.Design.Interaction.dll (under %devenvdir%\PublicAssemblies, i.e. c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies on 32bit Windows), it is not supported by Blend2 or Visual Studio 2008 for Silverlight. It is supported by Blend3 and Visual Studio 2010, but they both switch to newer version of Microsoft.Windows.Design*.dll (3.7 for Blend 3 Preview, 4.0 for Blend 3 RTM and Visual Studio 2010), so we need to link against the newer version of MWDs. Please see prior post <a href="http://www.ningzhang.org/2009/03/31/how-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010/" target="_blank">How to Write Silverlight Design Time for All Designers: Visual Studio 2008, Blend 2; Blend 3, and Visual Studio 2010</a> for more information.</p>
<p>Please also notice that reference to Silverlight’s System.Windows.dll is aliased, and the PointCollection is specifically called out to be the Silverlight one, not WPF’s. Since WPF and Silverlight share a lot of classes in same namespaces, <em>it is important that Silverlight types, not WPF’s, are used in creating ModelItem and ModelProperty in default initializer for Silverlight controls</em>.</p>
<h4>Collections</h4>
<p>Please note in below screenshot that while all other property value can be set via ModelProperty.SetValue:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image15.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ChartDefaultInitializer" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb11.png" border="0" alt="ChartDefaultInitializer" width="604" height="429" /></a></p>
<p>Chart.Series is of collection type (Collection&lt;Series&gt;), so its value has to be set by first creating a ModelItem via ModelFactory.CreateItem for the value, and then add the created ModelItem via ModelProperty.Collection.Add. Otherwise, even though the correct xaml may be generated, Blend won’t refresh to render the Chart control correctly, you have to reload the page to have it rendered correctly.</p>
<h4>ChartDefaultInitializer.cs</h4>
<p>
<div id="codeSnippetWrapper" class="csharpcode-wrapper">
<pre id="codeSnippet" class="csharpcode"><span class="rem">// (c) Copyright Microsoft Corporation.</span>
<span class="rem">// This source is subject to the Microsoft Public License (Ms-PL).</span>
<span class="rem">// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.</span>
<span class="rem">// All other rights reserved.</span>

<span class="kwrd">extern</span> alias Silverlight;
<span class="kwrd">using</span> System.Windows.Controls.DataVisualization.Charting;
<span class="kwrd">using</span> System.Windows.Controls.Design.Common;
<span class="kwrd">using</span> Microsoft.Windows.Design.Metadata;
<span class="kwrd">using</span> Microsoft.Windows.Design.Model;
<span class="kwrd">using</span> SSW = Silverlight::System.Windows;
<span class="kwrd">using</span> SSWD = Silverlight::System.Windows.Data;
<span class="kwrd">using</span> SSWM = Silverlight::System.Windows.Media;

<span class="kwrd">namespace</span> System.Windows.Controls.DataVisualization.Design
{
    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Default initializer for chart. </span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">internal</span> <span class="kwrd">class</span> ChartDefaultInitializer : DefaultInitializer
    {
        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Sets the default property values for chart. </span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="item"&gt;Chart ModelItem.&lt;/param&gt;</span>
        <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">void</span> InitializeDefaults(ModelItem item)
        {
            <span class="kwrd">string</span> propertyName;

            <span class="rem">// &lt;Charting:Chart Title="Chart Title"&gt;</span>
            propertyName = Extensions.GetMemberName&lt;Chart&gt;(x =&gt; x.Title);
            item.Properties[propertyName].SetValue(Properties.Resources.ChartTitle);

            <span class="rem">// &lt;Charting:Chart.DataContext&gt;</span>
            <span class="rem">//     &lt;PointCollection&gt;</span>
            <span class="rem">//         &lt;Point X="1" Y="10" /&gt;</span>
            <span class="rem">//         &lt;Point X="2" Y="20" /&gt;</span>
            <span class="rem">//         &lt;Point X="3" Y="30" /&gt;</span>
            <span class="rem">//         &lt;Point X="4" Y="40" /&gt;</span>
            <span class="rem">//     &lt;/PointCollection&gt;</span>
            <span class="rem">// &lt;/Charting:Chart.DataContext&gt;</span>

            SSWM::PointCollection defaultItemsSource = <span class="kwrd">new</span> SSWM::PointCollection();
            <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 1; i &lt;= 4; i++)
            {
                defaultItemsSource.Add(<span class="kwrd">new</span> SSW::Point(i, 10 * i));
            }

            propertyName = Extensions.GetMemberName&lt;Chart&gt;(x =&gt; x.DataContext);
            item.Properties[propertyName].SetValue(defaultItemsSource);

            <span class="rem">// &lt;Charting:Chart.Series&gt;</span>
            <span class="rem">//     &lt;Charting:ColumnSeries ItemsSource="{Binding}"</span>
            <span class="rem">//         DependentValuePath="X"</span>
            <span class="rem">//         IndependentValuePath="Y" /&gt;</span>
            <span class="rem">// &lt;/Charting:Chart.Series&gt;</span>

            ModelItem columnSeries = ModelFactory.CreateItem(item.Context, <span class="kwrd">typeof</span>(ColumnSeries));
            propertyName = Extensions.GetMemberName&lt;ColumnSeries&gt;(x =&gt; x.ItemsSource);
            columnSeries.Properties[propertyName].SetValue(ModelFactory.CreateItem(columnSeries.Context, <span class="kwrd">typeof</span>(SSWD::Binding)));
            propertyName = Extensions.GetMemberName&lt;ColumnSeries&gt;(x =&gt; x.DependentValuePath);
            columnSeries.Properties[propertyName].SetValue(<span class="str">"X"</span>);
            propertyName = Extensions.GetMemberName&lt;ColumnSeries&gt;(x =&gt; x.IndependentValuePath);
            columnSeries.Properties[propertyName].SetValue(<span class="str">"Y"</span>);

            propertyName = Extensions.GetMemberName&lt;Chart&gt;(x =&gt; x.Series);
            item.Properties[propertyName].Collection.Add(columnSeries);
        }
    }
}</pre>
 </div>
</p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:49cdd6b9-c83e-4dd1-bc75-612e7b84e51b" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Silverlight">Silverlight</a>,<a rel="tag" href="http://technorati.com/tags/Design">Design</a>,<a rel="tag" href="http://technorati.com/tags/DefaultInitializer">DefaultInitializer</a>,<a rel="tag" href="http://technorati.com/tags/ModelItem">ModelItem</a>,<a rel="tag" href="http://technorati.com/tags/ModelProperty">ModelProperty</a>,<a rel="tag" href="http://technorati.com/tags/ModelEvent">ModelEvent</a>,<a rel="tag" href="http://technorati.com/tags/ModelFactory">ModelFactory</a>,<a rel="tag" href="http://technorati.com/tags/ModelService">ModelService</a></div>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;title=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls&amp;notes=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20uses%20the%20Chart%20default%20initializer%20to%20illustrate%20how%20to%20implement%20default%20initializer%20for%20Silverlight%20controls%2C%20and%20explain%20the%20underlying%20editing%20model%20architecture." title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;title=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20uses%20the%20Chart%20default%20initializer%20to%20illustrate%20how%20to%20implement%20default%20initializer%20for%20Silverlight%20controls%2C%20and%20explain%20the%20underlying%20editing%20model%20architecture." title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;t=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;title=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls&amp;annotation=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20uses%20the%20Chart%20default%20initializer%20to%20illustrate%20how%20to%20implement%20default%20initializer%20for%20Silverlight%20controls%2C%20and%20explain%20the%20underlying%20editing%20model%20architecture." title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;title=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;t=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls&opener=bm&amp;ei=UTF-8&amp;d=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20uses%20the%20Chart%20default%20initializer%20to%20illustrate%20how%20to%20implement%20default%20initializer%20for%20Silverlight%20controls%2C%20and%20explain%20the%20underlying%20editing%20model%20architecture." title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;t=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F11%2Fediting-model-default-initializer-for-silverlight-controls%2F&amp;title=Editing%20Model%20%26%20Default%20Initializer%20for%20Silverlight%20Controls&amp;bodytext=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20uses%20the%20Chart%20default%20initializer%20to%20illustrate%20how%20to%20implement%20default%20initializer%20for%20Silverlight%20controls%2C%20and%20explain%20the%20underlying%20editing%20model%20architecture." title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/44AOjbTmESE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/05/11/editing-model-default-initializer-for-silverlight-controls/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/05/11/editing-model-default-initializer-for-silverlight-controls/</feedburner:origLink></item>
		<item>
		<title>Migrate Windows Live Writer Data</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/U9oHUBH5DrI/</link>
		<comments>http://www.ningzhang.org/2009/05/08/migrate-windows-live-writer-data/#comments</comments>
		<pubDate>Fri, 08 May 2009 15:09:28 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Windows Live Writer]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/05/08/migrate-windows-live-writer-data/</guid>
		<description>This post discusses where Windows Live Writer saves its settings and data (like auto linking, dictionary, posts etc), how to migrate those data and settings, and how to find out more about Windows Live Writer via tools like procmon, reflector, and windbg.</description>
			<content:encoded><![CDATA[<p>I am re-imaging my laptop with Windows 7 RC: it is so much fun and productivity boost to spend a day or two re-installing and re-configuring OS and apps <img src='http://www.ningzhang.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  One of my favorite apps is <a href="http://download.live.com/writer" target="_blank">Windows Live Writer</a>, so I need to migrate all my Windows Live Writer settings and data. This is what I did:</p>
<ul>
<li><a href="http://technet.microsoft.com/en-us/library/cc733145.aspx" target="_blank">robocopy</a> posts under “%userprofile%\Documents\My Weblog Posts”</li>
<li>copy auto linking entries in “%appdata%\Windows Live Writer\LinkGlossary\linkglossary.xml”</li>
</ul>
<p>For those curious, this is where Windows Live Writer settings are stored:</p>
<ul>
<li>posts:<br />
<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="WLW posts directory" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image5.png" border="0" alt="WLW posts directory" width="447" height="289" /></li>
<li>User dictionaries, keywords and auto links:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image10.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="WLW config directory" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb6.png" border="0" alt="WLW config directory" width="554" height="295" /></a></li>
<li>other settings in registry:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image11.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="WLW settings in registry" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb7.png" border="0" alt="WLW settings in registry" width="554" height="270" /></a></li>
</ul>
<p>For those even more curious, this is how I found out where those settings are, besides web search:</p>
<ul>
<li> configuration is usually persisted in registry and/or files, and those registry and files usually follow well known path convention. Registry is usually a good start. For files, try %appdata% and/or &#8220;%userprofile%.</li>
<li>use <a href="http://technet.microsoft.com/en-us/sysinternals/default.aspx" target="_blank">sysinternals</a>’ <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" target="_blank">procmon</a> to see what registry and files a process is accessing:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image8.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="procmon on linkglossary.xml" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb4.png" border="0" alt="procmon on linkglossary.xml" width="554" height="198" /></a></li>
<li>for managed code, load all their assemblies (usually under %programfiles%) into <a href="http://en.wikipedia.org/wiki/.NET_Reflector" target="_blank">reflector</a>, and see how it is implemented:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image9.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="reflector on LinkGlossary" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb5.png" border="0" alt="reflector on LinkGlossary" width="554" height="277" /></a></li>
</ul>
<ul> Happy blogging, and hacking <img src='http://www.ningzhang.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </ul>
<p> </p>
<p> </p>
<p> </p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1848c3e0-d0d2-4742-ae17-eec381875305" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/Windows+Live+Writer">Windows Live Writer</a></div>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Migrate%20Windows%20Live%20Writer%20Data&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;title=Migrate%20Windows%20Live%20Writer%20Data&amp;notes=This%20post%20discusses%20where%20Windows%20Live%20Writer%20saves%20its%20settings%20and%20data%20%28like%20auto%20linking%2C%20dictionary%2C%20posts%20etc%29%2C%20how%20to%20migrate%20those%20data%20and%20settings%2C%20and%20how%20to%20find%20out%20more%20about%20Windows%20Live%20Writer%20via%20tools%20like%20procmon%2C%20reflector%2C%20and%20windbg." title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;title=Migrate%20Windows%20Live%20Writer%20Data&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=This%20post%20discusses%20where%20Windows%20Live%20Writer%20saves%20its%20settings%20and%20data%20%28like%20auto%20linking%2C%20dictionary%2C%20posts%20etc%29%2C%20how%20to%20migrate%20those%20data%20and%20settings%2C%20and%20how%20to%20find%20out%20more%20about%20Windows%20Live%20Writer%20via%20tools%20like%20procmon%2C%20reflector%2C%20and%20windbg." title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;t=Migrate%20Windows%20Live%20Writer%20Data" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;title=Migrate%20Windows%20Live%20Writer%20Data&amp;annotation=This%20post%20discusses%20where%20Windows%20Live%20Writer%20saves%20its%20settings%20and%20data%20%28like%20auto%20linking%2C%20dictionary%2C%20posts%20etc%29%2C%20how%20to%20migrate%20those%20data%20and%20settings%2C%20and%20how%20to%20find%20out%20more%20about%20Windows%20Live%20Writer%20via%20tools%20like%20procmon%2C%20reflector%2C%20and%20windbg." title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;title=Migrate%20Windows%20Live%20Writer%20Data" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;t=Migrate%20Windows%20Live%20Writer%20Data&opener=bm&amp;ei=UTF-8&amp;d=This%20post%20discusses%20where%20Windows%20Live%20Writer%20saves%20its%20settings%20and%20data%20%28like%20auto%20linking%2C%20dictionary%2C%20posts%20etc%29%2C%20how%20to%20migrate%20those%20data%20and%20settings%2C%20and%20how%20to%20find%20out%20more%20about%20Windows%20Live%20Writer%20via%20tools%20like%20procmon%2C%20reflector%2C%20and%20windbg." title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;t=Migrate%20Windows%20Live%20Writer%20Data" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F08%2Fmigrate-windows-live-writer-data%2F&amp;title=Migrate%20Windows%20Live%20Writer%20Data&amp;bodytext=This%20post%20discusses%20where%20Windows%20Live%20Writer%20saves%20its%20settings%20and%20data%20%28like%20auto%20linking%2C%20dictionary%2C%20posts%20etc%29%2C%20how%20to%20migrate%20those%20data%20and%20settings%2C%20and%20how%20to%20find%20out%20more%20about%20Windows%20Live%20Writer%20via%20tools%20like%20procmon%2C%20reflector%2C%20and%20windbg." title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/U9oHUBH5DrI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/05/08/migrate-windows-live-writer-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/05/08/migrate-windows-live-writer-data/</feedburner:origLink></item>
		<item>
		<title>Photoblog with WordPress</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/et6uMvi3BUs/</link>
		<comments>http://www.ningzhang.org/2009/05/04/photoblog-with-wordpress/#comments</comments>
		<pubDate>Tue, 05 May 2009 07:07:02 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[photoblog]]></category>
		<category><![CDATA[Windows Live Writer]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/?p=360</guid>
		<description>This blog discusses how to do photoblog with Windows Live Photo Gallery, Windows Live Writer, WordPress, NextGEN gallery, and WP-SimpleViewer.</description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>I’ve been using <a href="http://spaces.live.com" target="_blank">Windows Live Spaces</a> for personal blogging, but since I moved my work blog to <a href="http://wordpress.org/" target="_blank">WordPress</a>, I wanted to build my personal blog with WordPress too. WordPress is a great blog software, but features for photo blogging, which my personal blog is mostly about, are lacking out of box. So I spent the past weekend experimenting with various desktop software and WordPress plugins, and here is the result:</p>
<p><img class="alignnone size-full wp-image-361" title="mypersonalblog" src="http://www.ningzhang.org/wp-content/uploads/2009/05/mypersonalblog.jpg" alt="mypersonalblog" width="608" height="1116" /></p>
<p>Basically my photoblog solution consists of:</p>
<ul>
<li>Build my WordPress blog site with <a href="http://wordpress.org/extend/plugins/wp-simpleviewer/" target="_blank">WP-SimpleViewer</a> and <a href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">NextGEN Gallery</a> plugins
<ul>
<li>WP-SimpleViewer for slow connection (&lt; 1mbps)</li>
<li>NextGEN Gallery for fast connection (&gt;10mbps), gallery, and widgets</li>
</ul>
</li>
<li>Manage photos locally using <a href="http://download.live.com/photogallery" target="_blank">Windows Live Photo Gallery</a> </li>
<li>Backup photos remotely on both Live Spaces and my WordPress site</li>
<li>Write blogs and cross post them to both Live Spaces and WordPress site using <a href="http://download.live.com/writer" target="_blank">Windows Live Writer</a></li>
</ul>
<h3>WP-SimpleViewer</h3>
<p><a href="http://wordpress.org/extend/plugins/wp-simpleviewer/" target="_blank">WP-SimpleViewer</a> plugin “enables you to easily add fancy <a href="http://www.airtightinteractive.com/simpleviewer/" target="_blank">SimpleViewer</a> Flash galleries to your posts and pages. The admin interface helps you to create the thumbs for a new gallery and change its settings.” The slideshow in the middle of the screenshot above is generated with WP-SimpleViewer. Besides the fancy UI and easy keyboard navigation for in-page photo viewing, the biggest benefit, to me at least, is that WP-SimpleViewer generates 20-30KB sized scaled down photos under reg folder, and 1-2KB sized thumbnails under tn subfolder, and display those photos instead of the originals in the slide show. This allows very slick photo viewing experience even on slow connections (&lt;1mbps).</p>
<p>It is pretty easy to install WP-SimpleViewer, but making it work isn’t so trivial. By default, it always hangs during gallery creation. The fix is to uncomment line 101 of wp-simpleviewer-admin.php:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #008000">/*If the plugin should hang up while it is creating the thumbs (last line on the admin is: "Now I am working on file xzy.jpg:") you</span>
<span style="color: #008000">can try to uncomment the following line (remove // ) to define a new memory limit (40MB in this case). More info on the plugins FAQ.*/</span>
<span style="color: #008000">//ini_set("memory_limit","40M");</span></pre>
</div>
<p>I changed it to ini_set(“memory_limit”, “120MB”). I also increased the limits in php.in:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60    ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M      ; Maximum amount of memory a script may consume (32MB)</pre>
</div>
<p>But even with those changes, WP-SimpleViewer still hangs when there are a lot of photos in one gallery.</p>
<p>Another trick I did is to set the images directory to wp-content/gallery instead of the default wp-content/photos in WP-SimpleViewer’s admin page, so the same original photos can be used by both <a href="http://wordpress.org/extend/plugins/wp-simpleviewer/" target="_blank">WP-SimpleViewer</a> and <a href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">NextGEN Gallery</a>.</p>
<p> </p>
<h3>NextGEN Gallery</h3>
<p><a href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="_blank">NextGen Gallery</a> is probably the most popular image gallery plugin for WordPress. It has a basic set of image gallery functions, like albums, tags, roles etc, and a set of <a href="http://faq.wordpress.com/2008/06/18/what-are-the-wordpress-shortcodes/" target="_blank">shortcode</a> for different rendering. NextGEN’s slideshow and PicLens view both display the original photos. My photos are usually 2-3MB in size, so they look great with fast connection (&gt;10mpbs), and can be displayed with <a href="http://www.cooliris.com/" target="_blank">cooliris</a> browser addin (need separate install) as shown below:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="cooliris view" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image1.png" border="0" alt="cooliris view" width="644" height="404" /></p>
<p>But that doesn’t really work with slow connections (&lt;1mbps): those MB sized photos take forever to download on slow connection, so I usually put both WP-SimpleViewer and NextGEN shortcode on a page. Besides the nice rendering UI, NextGEN Gallery also comes with two nice widgets: the NextGEN Slideshow and NextGEN Gallery widget, as shown at the top left corner of my personal blog screenshot above.</p>
<p>Just like WP-SimpleViewer, it is pretty easy to install to NextGEN Gallery, but it takes some effort to make it work. Besides modifying php.ini as mentioned above, I also need to uncomment line 168 of lib/gd.thumbnail.inc.php:</p>
<blockquote><p>lib\gd.thumbnail.inc.php:168:           // @ini_set(&#8217;memory_limit&#8217;, &#8216;128M&#8217;);</p></blockquote>
<p>Once working, it seems more reliable than WP-SimpleViewer.</p>
<p> </p>
<h3>Windows Live Photo Gallery</h3>
<p>I used to use <a href="http://en.wikipedia.org/wiki/Picasa" target="_blank">Picasa</a>, but after trying out the new Windows Live Photo Gallery 2009, I am really impressed. The features I really like about Windows Live Photo Gallery:</p>
<ul>
<li>easy navigation with folder, date, people and tag hierarchical views</li>
<li>tagging, rating, and people tagging features</li>
<li>metadata in the info panel</li>
<li>fix functions, especially <a href="http://blogs.msdn.com/pix/archive/2008/10/21/straighten-up.aspx" target="_blank">straighten photo</a>: I am getting into the habit of applying it on all photos <img src='http://www.ningzhang.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>easy publishing to live spaces, and other photo sharing sites (require plugin)</li>
<li>and the publishing plugin platform</li>
</ul>
<h3>Windows Live Writer</h3>
<p><a href="http://download.live.com/writer" target="_blank">Windows Live Writer</a> is probably the best blog authoring tool. The nice new feature related to photo blogging is the Insert –&gt; Photo album… function:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Window Live Writer - Insert Photo Album Dialog" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb.png" border="0" alt="Window Live Writer - Insert Photo Album Dialog" width="493" height="484" /></a></p>
<p>It is nicely integrated with Live Spaces, allowing users to browse their existing photo albums or create new one, and insert it into blog post with four different layout. In my personal blog screenshot above, the top photo album in scatter view is inserted via Insert –&gt; Photo album. You can find more from <a href="http://windowslivewriter.spaces.live.com/Blog/" target="_blank">Windows Live Writer blog</a>, like post <a href="http://windowslivewriter.spaces.live.com/Blog/cns!D85741BB5E0BE8AA!1650.entry" target="_blank">Windows Live Writer 2009: Now Available for Download</a>.</p>
<p>Photo in Live Spaces are also doubled scaled for easy browsing on both slow and fast connections, just like WP-SimpleViewer: thumbnail and regular photos are displayed, but user can also click on a photo to get the original version. Live Spaces allows 25GB for photo storage, so it can be used as an online storage for photos.</p>
<p> </p>
<h3>Conclusion</h3>
<p> </p>
<p>I am by no means a blog or photoblog expert, and don’t really know WordPress, PHP, or the various Live services as a developer. This post is just to share what I’ve learned about photo blogging with WordPress. I am actually quite happy with what I’ve managed to do over the weekend. It is good enough for me for now, photo blogging wise.</p>
<p> </p>
<p> </p>
<div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0dc6a37b-ad67-445e-9b6c-7f7f3af327bc" class="wlWriterEditableSmartContent" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px">Technorati Tags: <a rel="tag" href="http://technorati.com/tags/photoblog">photoblog</a>,<a rel="tag" href="http://technorati.com/tags/wordpress">wordpress</a>,<a rel="tag" href="http://technorati.com/tags/nextgen+gallery">nextgen gallery</a>,<a rel="tag" href="http://technorati.com/tags/wp-simpleviewer">wp-simpleviewer</a>,<a rel="tag" href="http://technorati.com/tags/windows+live">windows live</a>,<a rel="tag" href="http://technorati.com/tags/windows+live+photo+gallery">windows live photo gallery</a>,<a rel="tag" href="http://technorati.com/tags/windows+live+writer">windows live writer</a>,<a rel="tag" href="http://technorati.com/tags/windows+live+spaces">windows live spaces</a>,<a rel="tag" href="http://technorati.com/tags/cooliris">cooliris</a></div>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Photoblog%20with%20WordPress&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;title=Photoblog%20with%20WordPress&amp;notes=This%20blog%20discusses%20how%20to%20do%20photoblog%20with%20Windows%20Live%20Photo%20Gallery%2C%20Windows%20Live%20Writer%2C%20WordPress%2C%20NextGEN%20gallery%2C%20and%20WP-SimpleViewer." title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;title=Photoblog%20with%20WordPress&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=This%20blog%20discusses%20how%20to%20do%20photoblog%20with%20Windows%20Live%20Photo%20Gallery%2C%20Windows%20Live%20Writer%2C%20WordPress%2C%20NextGEN%20gallery%2C%20and%20WP-SimpleViewer." title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;t=Photoblog%20with%20WordPress" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;title=Photoblog%20with%20WordPress&amp;annotation=This%20blog%20discusses%20how%20to%20do%20photoblog%20with%20Windows%20Live%20Photo%20Gallery%2C%20Windows%20Live%20Writer%2C%20WordPress%2C%20NextGEN%20gallery%2C%20and%20WP-SimpleViewer." title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;title=Photoblog%20with%20WordPress" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;t=Photoblog%20with%20WordPress&opener=bm&amp;ei=UTF-8&amp;d=This%20blog%20discusses%20how%20to%20do%20photoblog%20with%20Windows%20Live%20Photo%20Gallery%2C%20Windows%20Live%20Writer%2C%20WordPress%2C%20NextGEN%20gallery%2C%20and%20WP-SimpleViewer." title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;t=Photoblog%20with%20WordPress" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F05%2F04%2Fphotoblog-with-wordpress%2F&amp;title=Photoblog%20with%20WordPress&amp;bodytext=This%20blog%20discusses%20how%20to%20do%20photoblog%20with%20Windows%20Live%20Photo%20Gallery%2C%20Windows%20Live%20Writer%2C%20WordPress%2C%20NextGEN%20gallery%2C%20and%20WP-SimpleViewer." title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/et6uMvi3BUs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/05/04/photoblog-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/05/04/photoblog-with-wordpress/</feedburner:origLink></item>
		<item>
		<title>Fix Windows Live Writer Issue with WordPress</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/Bgb0oqvucYs/</link>
		<comments>http://www.ningzhang.org/2009/04/30/fix-windows-live-writer-issue-with-wordpress/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 17:33:02 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Windows Live Writer]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/04/30/fix-windows-live-writer-issue-with-wordpress/</guid>
		<description>This post discusses how to fix Windows Live Writer publish issues with WordPress site, especially the issue of invalid server response from XmlRpc server.</description>
			<content:encoded><![CDATA[<p>I have always been using <a href="http://download.live.com/writer" target="_blank">Windows Live Writer</a> (WLW) in writing my blogs and cross posting them to both WordPress site <a href="http://www.ningzhang.org">www.ningzhang.org</a> and Blogger site <a href="http://download.live.com/writer" target="_blank">blog.ningzhang.org</a>, very convenient. Yesterday I ran into issues opening and posting to my <a href="http://wordpress.org/" target="_blank">WordPress</a> site using Windows Live Writer: got an error dialog saying</p>
<blockquote><p>Invalid Server Response &#8211; The response to the metaWeblog.newMediaObject method received from the blog server was invalid</p></blockquote>
<p>I searched the web, tried a few things, and fixed the issue pretty quickly. Share my findings here in hope it may be helpful for others run into similar problems.</p>
<h4>Windows Live Writer Log</h4>
<p>WLW has pretty good log. Open Help-&gt;About Windows Live Writer menu item:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image17.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Windows Live Writer Help-&gt;About menu item" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb16.png" border="0" alt="Windows Live Writer Help-&gt;About menu item" width="602" height="484" /></a></p>
<p>You will see the About dialog, click the Show log file link:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="WLW About Windows" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb17.png" border="0" alt="WLW About Windows" width="385" height="292" /></p>
<p>the folder “%localappdata%\Windows Live Writer” will pop up, which contains “Windows Live Writer.log” file. I copied relevant error log below. Pretty good stack trace, very helpful for debugging and diagnosing <img src='http://www.ningzhang.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">WindowsLiveWriter,1.7696,Fail,00031,30-Apr-2009 01:28:58.595,"WindowsLive.Writer.Extensibility.BlogClient.BlogClientInvalidServerResponseException: Invalid Server Response - The response to the metaWeblog.newMediaObject method received from the blog server was invalid:

Invalid response document returned from XmlRpc server
   at WindowsLive.Writer.BlogClient.Clients.XmlRpcBlogClient.CallMethod(String methodName, XmlRpcValue[] parameters)
   at WindowsLive.Writer.BlogClient.Clients.MetaweblogClient.DoBeforePublishUploadWork(IFileUploadContext uploadContext)
   at WindowsLive.Writer.PostEditor.WeblogBlogFileUploader.DoUploadWorkBeforePublish(IFileUploadContext uploadContext)
   at WindowsLive.Writer.PostEditor.BlogPostReferenceFixer.FileUploadWorker.DoUploadWork(String fileReference, BlogFileUploader fileUploader, Boolean isWindowsLiveLightboxCloneEnabled)
   at WindowsLive.Writer.PostEditor.BlogPostReferenceFixer.LocalFileTransformer.Transform(BeginTag tag, String reference)
   at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.LocalFileReferenceFixupFilter.FixReferences(BeginTag tag, String reference)
   at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.OnBeginTag(BeginTag tag)
   at WindowsLive.Writer.CoreServices.LightWeightHTMLDocumentIterator.Parse()
   at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.FixReferences(TextWriter output, ReferenceFixer referenceFixer, ReferenceFixedCallback referenceFixed)
   at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.FixReferences(String html, ReferenceFixer fixer, ReferenceFixedCallback referenceFixed)
   at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.FixLocalFileReferences(String html, ReferenceFixer fixer, ReferenceFixedCallback referenceFixed)
   at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.FixLocalFileReferences(String html, ReferenceFixer fixer)
   at WindowsLive.Writer.PostEditor.UpdateWeblogAsyncOperation.LocalSupportingFileUploader.UploadFilesBeforePublish()
   at WindowsLive.Writer.PostEditor.UpdateWeblogAsyncOperation.DoWork()
   at WindowsLive.Writer.CoreServices.AsyncOperation.InternalStart()","   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at WindowsLive.Writer.CoreServices.Diagnostics.LogFileTraceListener.Fail(String message)
   at System.Diagnostics.TraceInternal.Fail(String message)
   at System.Diagnostics.Trace.Fail(String message)
   at WindowsLive.Writer.PostEditor.BlogPostEditingManager.UpdateWeblog(Boolean publish)
   at WindowsLive.Writer.PostEditor.BlogPostEditingManager.PostToWeblog(Boolean publish)
   at WindowsLive.Writer.PostEditor.BlogPostEditingManager.PublishAsDraft()
   at WindowsLive.Writer.PostEditor.PostEditorMainControl.commandPostAsDraft_Execute(Object sender, EventArgs e)
   at WindowsLive.Writer.ApplicationFramework.Command.RaiseEvent(Object eventKey, EventArgs e)
   at WindowsLive.Writer.ApplicationFramework.Command.OnExecute(EventArgs e)
   at WindowsLive.Writer.ApplicationFramework.CommandOwnerDrawMenuItem.OnClick(EventArgs e)
   at System.Windows.Forms.MenuItem.MenuItemData.Execute()
   at System.Windows.Forms.Command.Invoke()
   at System.Windows.Forms.Command.DispatchID(Int32 id)
   at System.Windows.Forms.Control.WmCommand(Message&amp; m)
   at System.Windows.Forms.Control.WndProc(Message&amp; m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message&amp; m)
   at System.Windows.Forms.ContainerControl.WndProc(Message&amp; m)
   at System.Windows.Forms.Form.WndProc(Message&amp; m)
   at WindowsLive.Writer.ApplicationFramework.ApplicationForm.WndProc(Message&amp; m)
   at WindowsLive.Writer.ApplicationFramework.SatelliteApplicationForm.WndProc(Message&amp; m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.WndProc(Message&amp; m)
   at WindowsLive.Writer.PostEditor.ImageInsertion.InsertImageDialog.ThumbnailReadinessListener.WndProc(Message&amp; m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at WindowsLive.Writer.ApplicationFramework.SatelliteApplicationForm.Launcher.ThreadMain(Object[] parameters)
   at WindowsLive.Writer.CoreServices.Threading.ThreadStartWithParams.Run()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()"</pre>
</div>
<h4>It is the Gold Star Rating Plugin!</h4>
<p>Since WLW has always worked fine with my WordPress site till now, so I suspect it is some recent changes on my WordPress site, and most likely recent plugin updates, so I tried deactivating plugins one by one. I was lucky! Since I knew what plugins I updated lately, so I first deactivated <a href="http://www.gdstarrating.com/" target="_blank">Gold Start Rating plugin</a> and then use WLW to open and post, and it worked!</p>
<p> </p>
<h4>Updates</h4>
<h5>2009-05-05</h5>
<p>I ran into this error again while publishing a post from Windows Live Writer:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Invalid Server Response" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image3.png" border="0" alt="Invalid Server Response" width="359" height="233" /></p>
<p>Windows Live Writer log shows similar error message and call stack as before. I opened error_log under the top directory of my WordPress site, it has something like this:</p>
<blockquote><p>05-May-2009 08:10:59] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 865469 bytes) in /[deleted]/wp-includes/class-IXR.php on line 242</p></blockquote>
<p>and line 242 of class-IXR.php is the second line below:</p>
<div>
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"><span style="color: #0000ff">case</span> <span style="color: #006080">'base64'</span>:
    $<span style="color: #0000ff">value</span> = base64_decode( trim( $<span style="color: #0000ff">this</span>-&gt;_currentTagContents ) );
    $valueFlag = <span style="color: #0000ff">true</span>;
    <span style="color: #0000ff">break</span>;</pre>
</div>
<p>So it looks like it ran out of memory while base64_decode an image. I removed the largest image in my post, post draft to blog, and it succeeded. I then edited the draft from WordPress web UI, select Add an Image from computer and insert it to post:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/05/image4.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Add an Image from computer" src="http://www.ningzhang.org/wp-content/uploads/2009/05/image-thumb1.png" border="0" alt="Add an Image from computer" width="644" height="209" /></a></p>
<p>and it succeeded.</p>
<p>I don’t really know WordPress or PHP as a developer, so if anyone know how to raise this better, please let me know. A general novice user approach seems:</p>
<ul>
<li>post draft to server frequently to pinpoint the troublemaker image while you are authoring</li>
<li>upload and insert the image to post from WordPress web UI</li>
</ul>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;title=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress&amp;notes=This%20post%20discusses%20how%20to%20fix%20Windows%20Live%20Writer%20publish%20issues%20with%20WordPress%20site%2C%20especially%20the%20issue%20of%20invalid%20server%20response%20from%20XmlRpc%20server.%20" title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;title=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=This%20post%20discusses%20how%20to%20fix%20Windows%20Live%20Writer%20publish%20issues%20with%20WordPress%20site%2C%20especially%20the%20issue%20of%20invalid%20server%20response%20from%20XmlRpc%20server.%20" title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;t=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;title=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress&amp;annotation=This%20post%20discusses%20how%20to%20fix%20Windows%20Live%20Writer%20publish%20issues%20with%20WordPress%20site%2C%20especially%20the%20issue%20of%20invalid%20server%20response%20from%20XmlRpc%20server.%20" title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;title=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;t=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress&opener=bm&amp;ei=UTF-8&amp;d=This%20post%20discusses%20how%20to%20fix%20Windows%20Live%20Writer%20publish%20issues%20with%20WordPress%20site%2C%20especially%20the%20issue%20of%20invalid%20server%20response%20from%20XmlRpc%20server.%20" title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;t=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Ffix-windows-live-writer-issue-with-wordpress%2F&amp;title=Fix%20Windows%20Live%20Writer%20Issue%20with%20WordPress&amp;bodytext=This%20post%20discusses%20how%20to%20fix%20Windows%20Live%20Writer%20publish%20issues%20with%20WordPress%20site%2C%20especially%20the%20issue%20of%20invalid%20server%20response%20from%20XmlRpc%20server.%20" title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/Bgb0oqvucYs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/04/30/fix-windows-live-writer-issue-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/04/30/fix-windows-live-writer-issue-with-wordpress/</feedburner:origLink></item>
		<item>
		<title>Register Silverlight Controls with Visual Studio and Blend</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/9-He14xyLxE/</link>
		<comments>http://www.ningzhang.org/2009/04/30/register-silverlight-controls-with-visual-studio-and-blend/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 08:31:44 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[AssemblyFoldersEx]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[March 2009 Release]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/?p=343</guid>
		<description>This is part of the series on design time feature implementation in Silverlight Toolkit. This post illustrates the integration of Silverlight Toolkit with Visual Studio and Blend 3, and explains how it is done, so you can register your own Silverlight controls with Visual Studio and Blend too.</description>
			<content:encoded><![CDATA[<p> </p>
<h3>Introduction</h3>
<p>This is part of the series on design time implementation changes in <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>. This post illustrates the integration of Silverlight Toolkit with Visual Studio and Blend 3 after running Silverlight 3 Toolkit March 2009 Installer, and explains how it is done, so you can register your own Silverlight controls with Visual Studio and Blend too.</p>
<p> </p>
<h3>Blend Integration</h3>
<p>After installing <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=11dc7151-dbd6-4e39-878f-5081863cbb5d&amp;displaylang=en" target="_blank">Silverlight 3 Beta1 Tools</a>, <a href="http://www.microsoft.com/expression/try-it/blendpreview.aspx" target="_blank">Blend 3 Preview</a>, and <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430#DownloadId=62369" target="_blank">Silverlight 3 Toolkit March 2009</a> (please see <a href="http://www.ningzhang.org/2009/03/19/silverlight-toolkit-design-time-features-march-2009-release-update/" target="_blank">Silverlight Toolkit Design Time Features: March 2009 Release Update</a>, Silverlight 3 Development with Visual Studio 2008 and Blend 3 section for more information), create a Silverlight 3 Application from Blend 3, we can see that Silverlight Toolkit controls show up automatically in Asset Library:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image24.png" target="_blank"><img title="Toolkit Controls in Asset Library, Controls Tab" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb21.png" alt="Toolkit Controls in Asset Library, Controls Tab" /></a></p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image25.png" target="_blank"><img title="Toolkit Controls in Asset Library, Custom Controls Tab" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb22.png" alt="Toolkit Controls in Asset Library, Custom Controls Tab" /></a> </p>
<p>User can drag and drop Toolkit controls from Asset Library to design or xaml view, and Blend will automatically add assembly reference, xmlns prefix and xaml code, very convenient:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image26.png" target="_blank"><img title="Drag and Drop Chart control from Asset Library" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb23.png" alt="Drag and Drop Chart control from Asset Library" /></a></p>
<p> </p>
<h3>Visual Studio Integration</h3>
<p>Open the project in Visual Studio, we can see that Toolkit controls show up automatically in Visual Studio Toolbox, and user can drag and drop controls from Toolbox to design or xaml view as well:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image30.png" target="_blank"><img title="Toolkit Controls in Visual Studio Toolbox" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb27.png" alt="Toolkit Controls in Visual Studio Toolbox" /></a> </p>
<p>Besides Toolbox, Toolkit assemblies also show up in Add Reference Dialog:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image12.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Add Reference Dialog" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb11.png" border="0" alt="Add Reference Dialog" width="644" height="374" /></a></p>
<p>and Choose Toolbox Items Dialog:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image13.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb12.png" border="0" alt="image" width="644" height="439" /></a></p>
<p> </p>
<h3>Implementation</h3>
<p>The integration with Visual Studio and Blend is done via registry. If you open “Silverlight 3 Toolkit March 2009.msi” in <a href="http://msdn.microsoft.com/en-us/library/aa370557.aspx" target="_blank">Orca</a>, you can see the registration magic:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image14.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Silverlight 3 Toolkit March 2009.msi in Orca" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb13.png" border="0" alt="Silverlight 3 Toolkit March 2009.msi in Orca" width="644" height="200" /></a></p>
<h4>Register with Visual Studio</h4>
<h5>AssemblyFoldersEx</h5>
<p>Registering with Visual Studio is mostly done via [HKLM|HKCU]\Software\Microsoft\Microsoft SDKs\Silverlight\v3.0\AssemblyFoldersEx:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image15.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Registration" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb14.png" border="0" alt="Visual Studio Registration" width="644" height="206" /></a></p>
<p>The <a href="http://fisheye1.atlassian.com/browse/~raw,r=1.1/nant/nant/etc/Reference%20Resolution%20in%20Visual%20Studio.htm" target="_blank">References in Visual Studio</a> page has very good explanation on AssemblyFoldersEx and reference resolution. It is a bit outdate, and is about .net instead of Silverlight, but it is mostly right for Silverlight too. I duplicated the registration schema section below, and modified it to fit Silverlight. Text in <em><span style="font-size: xx-small;">small italic fonts</span></em> are purely hypothetical, meaning: it doesn’t work for Silverlight today; I have it here simply because it is in originally text, works for .NET, and <em>seems</em> making sense for Silverlight to duplicate or to be consistent with .Net.</p>
<h6>Registration Schema</h6>
<p>Assembly directories can be added to the registry so that the build process can resolve references to assemblies in those directories. Here’s an example of the registry schema.</p>
<blockquote><p>[HKLM | HKCU]\SOFTWARE\MICROSOFT\Silverlight\</p>
<p>  v3.0</p>
<p>    AssemblyFoldersEx</p>
<p>      Silverlight Toolkit</p>
<p>        @Default = C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Toolkit\March 2009\Libraries\</p>
<p>        @Description = Silverlight 3 Toolkit March 2009</p>
<p><em><span style="font-size: xx-small;">        20090401</span></em></p>
<p><em><span style="font-size: xx-small;">          @Default = C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Toolkit\March 2009\20090401</span></em></p>
<p><em><span style="font-size: xx-small;">          @Description = April Fool’s Updates</span></em></p></blockquote>
<p>In the above example, there are several interesting fields.</p>
<p>(1) AssemblyFolderBase – The registry path &#8220;\SOFTWARE\MICROSOFT\Silverlight&#8221; indicates the target framework platform. Typical values for this property are:</p>
<p>\SOFTWARE\MICROSOFT\Silverlight(default) – for Silverlight</p>
<p><em><span style="font-size: xx-small;">\SOFTWARE\MICROSOFT\.NetCompactFramework– for .NET Compact Framework </span></em></p>
<p>(2) FrameworkVersion – The version of the frameworks that this component is meant to work against.</p>
<p>(3) AssemblyFoldersSuffix – Describes the sub-target, examples include:</p>
<p>AssemblyFoldersEx (default) – for Silverlight</p>
<p><em><span style="font-size: xx-small;">PocketPC\AssemblyFoldersEx – for the .NET Compact Framework for Pocket PC</span></em></p>
<p><em><span style="font-size: xx-small;">SmartPhone\AssemblyFoldersEx – for the .NET Compact Framework for SmartPhone</span></em></p>
<p><em><span style="font-size: xx-small;">WindowsCE\AssemblyFoldersEx – for the .NET Compact Framework for WindowsCE</span></em></p>
<p>(4) ControlName – The name of the control. In the example above, “Silverlight 3 Toolkit March 2009”. The control vendor chooses this name.</p>
<p><em><span style="font-size: xx-small;">(5) ServicingCode – For service packs that update the same component. In the above example, “20090401”. The control vendor chooses this name.</span></em></p>
<p><em></em></p>
<h5>Toolbox Controls Installer</h5>
<p><a href="http://blogs.msdn.com/jnak" target="_blank">Jim Nakashima</a> blogged about <a href="http://msdn.microsoft.com/en-us/library/bb286995(VS.80).aspx" target="_blank">Toolbox Controls Installer</a> for WPF controls in his post <a href="http://blogs.msdn.com/jnak/archive/2007/09/26/have-you-seen-the-toolbox-controls-installer.aspx" target="_blank">Have you seen the Toolbox Controls Installer?</a> in 2007. Toolbox Controls Installer package is now part of Visual Studio 2008, and kind of works, with a bug that will be fixed in Visual Studio 2010. It can be tweaked to work for Silverlight controls too: set string registry value SilverlightControls instead of WPFControls to 1.</p>
<p> </p>
<p>I am working with various teams inside Microsoft to improve the Visual Studio registration story for Silverlight controls. All feedbacks and suggestions are welcome!</p>
<h4>Register with Blend</h4>
<p>Registering with Blend is via HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Expression\Blend\v3.0\Toolbox\Silverlight\v3.0:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image16.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blend Registration" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb15.png" border="0" alt="Blend Registration" width="644" height="206" /></a></p>
<p><a href="http://blogs.msdn.com/unnir" target="_blank">Unni Ravindranathan</a>’s blog post <a href="http://blogs.msdn.com/unnir/archive/2009/03/17/blend-3-extensibility.aspx" target="_blank">Blend 3 Extensibility</a> has more information about this mechanism. One caveat: if the registered assemblies depend on other assemblies, those other assemblies need to be in the same directory as registered assemblies, or registered with AssemblyFoldersEx mentioned above. </p>
<p> </p>
<h3>Conclusion</h3>
<p>Registration with Visual Studio and Blend makes Silverlight Toolkit controls a lot easier to use for developers. We are constantly looking at improving the registration mechanism in hope to make it simple and consistent across designers (Visual Studio and Blend) and technologies (WPF and Silverlight). All feedbacks are welcome!</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;title=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend&amp;notes=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20illustrates%20the%20integration%20of%20Silverlight%20Toolkit%20with%20Visual%20Studio%20and%20Blend%203%2C%20and%20explains%20how%20it%20is%20done%2C%20so%20you%20can%20register%20your%20own%20Silverlight%20controls%20with%20Visual%20Studio%20and%20Blend%20too.%0D%0A" title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;title=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20illustrates%20the%20integration%20of%20Silverlight%20Toolkit%20with%20Visual%20Studio%20and%20Blend%203%2C%20and%20explains%20how%20it%20is%20done%2C%20so%20you%20can%20register%20your%20own%20Silverlight%20controls%20with%20Visual%20Studio%20and%20Blend%20too.%0D%0A" title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;t=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;title=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend&amp;annotation=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20illustrates%20the%20integration%20of%20Silverlight%20Toolkit%20with%20Visual%20Studio%20and%20Blend%203%2C%20and%20explains%20how%20it%20is%20done%2C%20so%20you%20can%20register%20your%20own%20Silverlight%20controls%20with%20Visual%20Studio%20and%20Blend%20too.%0D%0A" title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;title=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;t=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend&opener=bm&amp;ei=UTF-8&amp;d=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20illustrates%20the%20integration%20of%20Silverlight%20Toolkit%20with%20Visual%20Studio%20and%20Blend%203%2C%20and%20explains%20how%20it%20is%20done%2C%20so%20you%20can%20register%20your%20own%20Silverlight%20controls%20with%20Visual%20Studio%20and%20Blend%20too.%0D%0A" title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;t=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F30%2Fregister-silverlight-controls-with-visual-studio-and-blend%2F&amp;title=Register%20Silverlight%20Controls%20with%20Visual%20Studio%20and%20Blend&amp;bodytext=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20illustrates%20the%20integration%20of%20Silverlight%20Toolkit%20with%20Visual%20Studio%20and%20Blend%203%2C%20and%20explains%20how%20it%20is%20done%2C%20so%20you%20can%20register%20your%20own%20Silverlight%20controls%20with%20Visual%20Studio%20and%20Blend%20too.%0D%0A" title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/9-He14xyLxE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/04/30/register-silverlight-controls-with-visual-studio-and-blend/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/04/30/register-silverlight-controls-with-visual-studio-and-blend/</feedburner:origLink></item>
		<item>
		<title>Add Rich Intellisense for Your Silverlight Controls</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/Cr_7vxCPEVQ/</link>
		<comments>http://www.ningzhang.org/2009/04/22/add-rich-intellisense-for-your-silverlight-controls/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 06:49:43 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Intellisense]]></category>
		<category><![CDATA[Silverlight SDK]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/?p=323</guid>
		<description>This post describes the rich intellisense support of Silverlight Toolkit and its implementation workflow from xmldoc comments to intellisense xml files to design dlls.</description>
			<content:encoded><![CDATA[<h4>Introduction</h4>
<p>This is part of the series on design time implementation changes in <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>. This post illustrates the rich  intellisense support for <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a>, and explains implementation workflow from  xmldoc in source to infotip in intellisense xml file and design assemblies.</p>
<h4>Intellisense</h4>
<p><a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> has rich Intellisense in code and XAML editors in both Visual Studio and Blend:</p>
<ul>
<li>Visual Studio Code Editor: <a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image34.png" target="_blank"><br />
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="VS2008 Code Editor Intellisense" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image34-thumb.png" border="0" alt="VS2008 Code Editor Intellisense" width="604" height="402" /></a></li>
<li>Blend 3 Code Editor: <a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image30.png" target="_blank"><br />
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blend 3 Code Editor Intellisense" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image30-thumb.png" border="0" alt="Blend 3 Code Editor Intellisense" width="604" height="389" /></a></li>
<li>Blend 3 XAML editor: <a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image26.png" target="_blank"><br />
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blend 3 Xaml Editor Intellisense" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image26-thumb.png" border="0" alt="Blend 3 Xaml Editor Intellisense" width="604" height="389" /></a></li>
</ul>
<p>Visual Studio XAML editor has intellisense too, but no infotip:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Visual Studio Xaml Editor Intellisense" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb6.png" border="0" alt="Visual Studio Xaml Editor Intellisense" width="644" height="429" /></a><br />
 </p>
<h4>Implementation</h4>
<h5>Code Editor Intellisense Infotip from XML Files</h5>
<p>The intellisense infotips in code editors in Visual Studio and Blend come from intellisense xml files installed under Silverlight SDK and Toolkit directories:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image7.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Intellisense xml files installed" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb7.png" border="0" alt="Intellisense xml files installed" width="644" height="373" /></a></p>
<h5>Localization</h5>
<p>Those intellisense xml files can be localized. If you install localized  Visual Studio and localized Silverlight SDK, you will see localized infotips,  which is a great help for those who don’t speak English. Below is the screenshot  of Visual Studio running with Simplified Chinese language and <a href="http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&amp;FamilyID=c22d6a7b-546f-4407-8ef6-d60c8ee221ed" target="_blank">simplified Chinese version of Silverlight Tools for Visual Studio  SP1</a>:<br />
 </p>
<p><img class="size-full wp-image-330 alignnone" title="Chinese Visual Studio and Infotip" src="http://www.ningzhang.org/wp-content/uploads/2009/04/vschs.jpg" alt="Chinese Visual Studio and Infotip" width="640" height="484" /></p>
<p>The Chinese infotip is from localized System.Windows.Controls.xml under zh-CHS  sub directory:</p>
<div style="line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: consolas, 'Courier New', courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: gray 1px solid; padding: 4px;">
<pre style="line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: consolas, 'Courier New', courier, monospace; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;">C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client&gt;dir/s /b system.windows.controls.xml
C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\system.windows.controls.xml
C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\zh-CHS\system.windows.controls.xml</pre>
</div>
<h5>XAML Editor Intellisense Infotip from Design Assemblies</h5>
<p>The intellisense infotips in Blend 3 XAML editor come from a different mechanism: they come from <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx" target="_blank">DescriptionAttribute</a> implemented by design dlls installed under the Design subdirectory:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image8.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SDK Design Directory" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb8.png" border="0" alt="image" width="644" height="462" /></a></p>
<p>So it is the same as infotips in Blend Properties panel (please see <a href="http://www.ningzhang.org/2008/12/13/design-time-features-in-silverlight-toolkit/" target="_blank">Design Time Features in Silverlight Toolkit</a> for more information):</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image9.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Blend Property Inspector Infotip" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb9.png" border="0" alt="Blend Property Inspector Infotip" width="644" height="415" /></a> </p>
<h5>xmldoc comment –&gt; intellisense xml file –&gt; DescriptionAttribute in design assembly</h5>
<p>All those infotips come from <a href="http://msdn.microsoft.com/en-us/library/b2s063f7.aspx" target="_blank">xml documentation comments</a> in source code, as seen from below screenshot:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image10.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Infotip workflow: from xmldoc to intellisense file to design dll" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb10.png" border="0" alt="image" width="588" height="484" /></a></p>
<ol>
<li>we put xmldoc comments in source code</li>
<li>build generates .xml files from those xmldoc comments</li>
<li>the generated .xml files are embedded in design dlls (see <a href="http://www.ningzhang.org/2008/12/28/design-time-feature-implementation-in-silverlight-toolkit/" target="_blank">Design Time Feature Implementation in Silverlight Toolkit</a> for more information)</li>
<li>the control dlls, design dlls, and xml files are installed by SDK and Toolkit setup</li>
</ol>
<h4>Conclusion</h4>
<p>This post describes the rich intellisense support of <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> and its implementation workflow from xmldoc comments to intellisense xml files to design dlls. Good commenting pays!</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;title=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls&amp;notes=This%20post%20describes%20the%20rich%20intellisense%20support%20of%20Silverlight%20Toolkit%20and%20its%20implementation%20workflow%20from%20xmldoc%20comments%20to%20intellisense%20xml%20files%20to%20design%20dlls.%20" title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;title=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls&amp;source=Ning+Zhang%26%23039%3Bs+Blog+About+Silverlight%2C+Microsoft+technologies%2C+and+software+development+in+general.&amp;summary=This%20post%20describes%20the%20rich%20intellisense%20support%20of%20Silverlight%20Toolkit%20and%20its%20implementation%20workflow%20from%20xmldoc%20comments%20to%20intellisense%20xml%20files%20to%20design%20dlls.%20" title="LinkedIn"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;t=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;title=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls&amp;annotation=This%20post%20describes%20the%20rich%20intellisense%20support%20of%20Silverlight%20Toolkit%20and%20its%20implementation%20workflow%20from%20xmldoc%20comments%20to%20intellisense%20xml%20files%20to%20design%20dlls.%20" title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;title=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;t=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls&opener=bm&amp;ei=UTF-8&amp;d=This%20post%20describes%20the%20rich%20intellisense%20support%20of%20Silverlight%20Toolkit%20and%20its%20implementation%20workflow%20from%20xmldoc%20comments%20to%20intellisense%20xml%20files%20to%20design%20dlls.%20" title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;t=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F22%2Fadd-rich-intellisense-for-your-silverlight-controls%2F&amp;title=Add%20Rich%20Intellisense%20for%20Your%20Silverlight%20Controls&amp;bodytext=This%20post%20describes%20the%20rich%20intellisense%20support%20of%20Silverlight%20Toolkit%20and%20its%20implementation%20workflow%20from%20xmldoc%20comments%20to%20intellisense%20xml%20files%20to%20design%20dlls.%20" title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/Cr_7vxCPEVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/04/22/add-rich-intellisense-for-your-silverlight-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/04/22/add-rich-intellisense-for-your-silverlight-controls/</feedburner:origLink></item>
		<item>
		<title>Property Value Editors for Silverlight Controls</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/Q34UqUjh5VQ/</link>
		<comments>http://www.ningzhang.org/2009/04/03/property-value-editors-for-silverlight-controls/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 19:24:34 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[March 2009 Release]]></category>
		<category><![CDATA[PropertyValueEditor]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[TypeConverter]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/?p=301</guid>
		<description>This is part of the series on design time implementation in Silverlight Toolkit. This post discusses how to enhance property editing experience for Silverlight controls using property value editor and type converter. I will start with describing the overall property editing architecture in WPF/Silverlight designer extensibility framework, then use examples in  Silverlight Toolkit March 2009 Release to demonstrate how it is done, and unique issues/tricks in Silverlight design time development.</description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This is part of the series on design time implementation changes in <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>. This post discusses how to enhance property editing experience for Silverlight controls using property value editor and type converter. I will start with describing the overall property editing architecture in WPF/Silverlight designer extensibility framework, then use examples in  <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a> to demonstrate how it is done, and unique issues/tricks in Silverlight design time development.</p>
<h3>Property Editing Architecture</h3>
<p>Visually editing object properties is an important part of designers. Designers usually don’t know how to render properties of custom type (struct, class or interface), much less to provide an nice editing user interface. Control developers usually need to provide <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverter.aspx" target="_blank">TypeConverter</a>, <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.aspx" target="_blank">PropertyValueEditor</a>, or both, to provide rendering/editing UI and XAML serialization for properties of custom types.</p>
<p>The designer extensibility framework defines three types of property value editor: inline editor, extended editor, and dialog editor, each implemented by a class:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="PropertyValueEditor class diagram" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb.png" border="0" alt="PropertyValueEditor class diagram" width="644" height="137" /></a></p>
<p>Editing UI of those editors are defined by <a href="http://msdn.microsoft.com/en-us/library/system.windows.datatemplate.aspx" target="_blank">DataTemplate</a>. The property being edited is exposed to editor as <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.datacontext.aspx" target="_blank">DataContext</a> of <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalue.aspx" target="_blank">PropertyValue</a> type. Editor UI usually bind to the underlying property being edited via one of the three properties of <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalue.aspx" target="_blank">PropertyValue</a>: <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalue.value.aspx" target="_blank">Value</a>, <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalue.stringvalue.aspx" target="_blank">StringValue</a>, or <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalue.collection.aspx" target="_blank">Collection</a>.</p>
<h4>PropertyValueEditor</h4>
<p><a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.aspx" target="_blank">PropertyValueEditor</a> holds a single inline editor defined by <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.inlineeditortemplate.aspx" target="_blank">InlineEditorTemplate</a> property. Inline editor appears inside the properties window. Below is an simple example of <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.inlineeditortemplate.aspx" target="_blank">InlineEditorTemplate</a> that uses a TextBox to display and edit a property:</p>
<div>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">="TextBoxEditor"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">TextBox</span> <span class="attr">Text</span><span class="kwrd">="{Binding Path=Value}"</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">DataTemplate</span><span class="kwrd">&gt;</span></pre>
</div>
<div> </div>
<h4>ExtendedPropertyValueEditor</h4>
<div><a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.extendedpropertyvalueeditor.aspx" target="_blank">ExtendedPropertyValueEditor</a> has two editors: an inline editor inherited from <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.aspx" target="_blank">PropertyValueEditor</a>, and an additional extended editor defined by the <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.extendedpropertyvalueeditor.extendededitortemplate.aspx" target="_blank">ExtendedEditorTemplate</a> property. The extended editor is usually popped up by inline editor via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditorcommands.aspx" target="_blank">PropertyValueEditorCommands</a>.<a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditorcommands.showextendedpinnededitor.aspx" target="_blank">ShowExtendedPinnedEditor</a> or <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditorcommands.aspx" target="_blank">PropertyValueEditorCommands</a>.<a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditorcommands.showextendedpopupeditor.aspx" target="_blank">ShowExtendedPopupEditor</a> command. Below is a simple example: the inline editor is a button; when clicked, it pops up the extended editor that uses a Slider to display and edit the underlying property.</div>
<div class="csharpcode-wrapper">
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">="inlineEditor"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Button</span> <span class="attr">Content</span><span class="kwrd">="..."</span> <span class="attr">Command</span><span class="kwrd">="{x:Static PropertyEditing:PropertyValueEditorCommands.ShowDialogEditor}"</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">DataTemplate</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">="extendedEditor"</span> <span class="attr">xmlns:PropertyEditing</span><span class="kwrd">="clr-namespace:Microsoft.Windows.Design.PropertyEditing;assembly=Microsoft.Windows.Design.Interaction"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Slider</span> <span class="attr">x:Name</span><span class="kwrd">="slider"</span> <span class="attr">Value</span><span class="kwrd">="{Binding Path=Value}"</span> <span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">DataTemplate</span><span class="kwrd">&gt;</span></pre>
</div>
<div> </div>
<h4>DialogPropertyValueEditor</h4>
<p><a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.dialogpropertyvalueeditor.aspx" target="_blank">DialogPropertyValueEditor</a> has two editors too: the inline editor inherited from <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.aspx" target="_blank">PropertyValueEditor</a>, and an additional dialog editor defined by <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.dialogpropertyvalueeditor.dialogeditortemplate.aspx" target="_blank">DialogEditorTemplate</a> property. The dialog editor is usually popped up by inline editor via <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditorcommands.aspx" target="_blank">PropertyValueEditorCommands</a>.<a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditorcommands.showdialogeditor.aspx" target="_blank">ShowDialogEditor</a> command. Below is a simple example:</p>
<div class="csharpcode-wrapper" style="width: 97.5%; height: 246px;">
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">="inlineEditor"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Button</span> <span class="attr">Content</span><span class="kwrd">="..."</span> <span class="attr">Command</span><span class="kwrd">="{x:Static PropertyEditing:PropertyValueEditorCommands.ShowDialogEditor}"</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">DataTemplate</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;</span><span class="html">DataTemplate</span> <span class="attr">x:Key</span><span class="kwrd">="dialogEditor"</span> <span class="attr">xmlns:PropertyEditing</span><span class="kwrd">="clr-namespace:Microsoft.Windows.Design.PropertyEditing;assembly=Microsoft.Windows.Design"</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Grid</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Grid.ColumnDefinitions</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">ColumnDefinition</span> <span class="attr">Width</span><span class="kwrd">="Auto"</span> <span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">ColumnDefinition</span> <span class="attr">Width</span><span class="kwrd">="*"</span> <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Grid.ColumnDefinitions</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">Grid.RowDefinitions</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">RowDefinition</span> <span class="attr">Height</span><span class="kwrd">="*"</span><span class="kwrd">/&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">RowDefinition</span> <span class="attr">Height</span><span class="kwrd">="*"</span><span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">Grid.RowDefinitions</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TextBlock</span> <span class="attr">Text</span><span class="kwrd">="User Name:"</span> <span class="attr">VerticalAlignment</span><span class="kwrd">="Center"</span> <span class="attr">HorizontalAlignment</span><span class="kwrd">="Right"</span> <span class="attr">Margin</span><span class="kwrd">="0,0,4,4"</span><span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">TextBox</span> <span class="attr">Text</span><span class="kwrd">="{Binding Path=Value}"</span> <span class="attr">VerticalAlignment</span><span class="kwrd">="Center"</span> <span class="attr">HorizontalAlignment</span><span class="kwrd">="Stretch"</span> <span class="attr">Margin</span><span class="kwrd">="0,0,4,4"</span> <span class="attr">Grid</span>.<span class="attr">Column</span><span class="kwrd">="1"</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">DataTemplate</span><span class="kwrd">&gt;</span></pre>
</div>
<p> </p>
<p> </p>
<h4>Implement Custom Property Editor</h4>
<p>To implement a custom property editor for a Silverlight control:</p>
<ul>
<li>implement a custom property editor class
<ul>
<li>inherit from PropertyValueEditor, ExtendedPropertyValueEditor, or DialogPropertyValueEditor</li>
<li>set its editor template(s): <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.inlineeditortemplate.aspx" target="_blank">InlineEditorTemplate</a>, <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.extendedpropertyvalueeditor.extendededitortemplate.aspx" target="_blank">ExtendedEditorTemplate</a>, and/or <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.dialogpropertyvalueeditor.dialogeditortemplate.aspx" target="_blank">DialogEditorTemplate</a>;</li>
</ul>
</li>
<li>Associate the custom property editor with a property of a Silverlight control via a AddCustomAttributes call, something like
<div>
<pre class="csharpcode">attributeTableBuilder.AddCustomAttributes(
    <span class="kwrd">typeof</span>(MyControl),
    <span class="str">"MyProperty"</span>,
    <span class="kwrd">new</span> PropertyValueEditor.CreateEditorAttribute(<span class="kwrd">typeof</span>(MyValueEditor)));</pre>
<p> </p></div>
</li>
</ul>
<ul>A correctly implemented property value editor must satisfy the following requirements:   </p>
<li>The property value editor must be designed so that the inline editor and extended editor parts can be used independently.</li>
<li>A property value editor must not store state. Property value editors are stateless, might be cached by a host implementation, and can be re-used across multiple property values.</li>
<li>A property value editor must not assume that only one value editor part (view/inline/extended) control is active at a given time. For example, a dialog box could have the view part, inline part, and extended UI part active at the same time.</li>
<li>A control implemented as part of a property value editor must not store state. A control implemented as part of a value editor should not assume that it will only be bound to one property value. Controls may be recycled to change different property values. Any information that is cached should be flushed if the data model is updated.</li>
<li>A control implemented as part of a property value editor must not make any assumptions about the host or its parent controls. The only communication mechanisms that should be used are the <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalue.aspx" target="_blank">PropertyValue</a> data model, by way of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.datacontext.aspx" target="_blank">DataContext</a>, and the standard set of commands.</li>
</ul>
<ul>You can read more about <a href="http://msdn.microsoft.com/en-us/library/bb514507.aspx" target="_blank">property editing architecture</a> and <a href="http://msdn.microsoft.com/en-us/library/bb546938.aspx" target="_blank">designer extensibility framework</a> on MSDN.</ul>
<ul> </ul>
<h3>Reference Both WPF and Silverlight Assemblies</h3>
<p>A design assembly is a .NET/WPF assembly loaded by Visual Studio or Blend, but it usually needs to reference Silverlight assemblies (at least the Silverlight control assembly it provides design time features for). This can create reference ambiguity for design assembly project: it sometimes needs to reference the same fully qualified type in both WPF and Silverlight, say System.Windows.FrameworkElement in both PresentationFramework.dll of WPF and System.Windows.dll of Silverlight. To avoid confusing Visual Studio, you can use <a href="http://msdn.microsoft.com/en-us/library/ms173212.aspx" target="_blank">extern alias</a> to distinguish WPF and Silverlight references.</p>
<p>For example, see the screenshot below for Controls.DataVisualization.Toolkit.Design project in Silverlight 3 Toolkit in <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image1.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb1.png" border="0" alt="image" width="644" height="460" /></a></p>
<ul>
<li>the project references both PresentationFramework and System.Windows, but System.Windows is under Silverlight alias, instead of the default global alias. The System.Windows reference under Silverlight alias is persisted in .csproj file as below:
<div class="csharpcode-wrapper">
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Reference</span> <span class="attr">Include</span><span class="kwrd">="System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL"</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">SpecificVersion</span><span class="kwrd">&gt;</span>False<span class="kwrd">&lt;/</span><span class="html">SpecificVersion</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">HintPath</span><span class="kwrd">&gt;</span>..\Binaries\System.Windows.dll<span class="kwrd">&lt;/</span><span class="html">HintPath</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Private</span><span class="kwrd">&gt;</span>False<span class="kwrd">&lt;/</span><span class="html">Private</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">Aliases</span><span class="kwrd">&gt;</span>Silverlight<span class="kwrd">&lt;/</span><span class="html">Aliases</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">Reference</span><span class="kwrd">&gt;</span></pre>
<p> </p></div>
</li>
<li>in source code, we add
<div>
<pre class="csharpcode"><span class="kwrd">extern</span> alias Silverlight;
<span class="kwrd">using</span> SSW = Silverlight::System.Windows;</pre>
<p> </p></div>
<p>and reference Silverlight’s FrameworkElement via SSW::FrameworkElement.</li>
</ul>
<h3>TextBoxEditor</h3>
<p>There is a inline editor TextBoxEditor in Controls.DataVisualization.Toolkit.Design project for displaying and editing Title property of object type for  [Area|Bar|Bubble|Column|Line|Pie|Scatter]Series and Chart controls, as shown below:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image2.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="TextBoxEditor" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb2.png" border="0" alt="TextBoxEditor" width="644" height="398" /></a></p>
<p>Text filled in Title field in Properties window on the right shows up automatically in XAML and design views in the middle.</p>
<p>The implementation of TextBoxEditor followed the steps outlined before:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image3.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="TextBoxEditor.cs" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb3.png" border="0" alt="TextBoxEditor.cs" width="644" height="460" /></a></p>
<ul>
<li>TextBoxEditor is a subclass of PropertyValueEditor. It sets <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.propertyediting.propertyvalueeditor.inlineeditortemplate.aspx" target="_blank">InlineEditorTemplate</a> in its default constructor. Here I use code instead of XAML to construct the <a href="http://msdn.microsoft.com/en-us/library/system.windows.datatemplate.aspx" target="_blank">DataTemplate</a>, because somehow I can’t get xaml to build, and everything in XAML can be rewritten in C# anyway.</li>
<li>It is associated with Chart.Title in ChartMetadata.cs (see <a href="http://www.ningzhang.org/2008/12/28/design-time-feature-implementation-in-silverlight-toolkit/" target="_blank">Design Time Feature Implementation in Silverlight Toolkit</a> for more information on *Metadata.cs files)</li>
</ul>
<p>TextBoxEditor.cs:</p>
<div class="csharpcode-wrapper">
<pre class="csharpcode"><span class="rem">// (c) Copyright Microsoft Corporation.</span>
<span class="rem">// This source is subject to the Microsoft Public License (Ms-PL).</span>
<span class="rem">// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.</span>
<span class="rem">// All other rights reserved.</span>

<span class="kwrd">using</span> System;
<span class="kwrd">using</span> Microsoft.Windows.Design.PropertyEditing;
<span class="kwrd">using</span> System.Windows;
<span class="kwrd">using</span> System.Windows.Data;

<span class="kwrd">namespace</span> System.Windows.Controls.DataVisualization.Design
{
    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Simple TextBox inline editor.</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> TextBoxEditor : PropertyValueEditor
    {
        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Preserve the constructor prototype from PropertyValueEditor.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="inlineEditorTemplate"&gt;Inline editor template.&lt;/param&gt;</span>
        <span class="kwrd">public</span> TextBoxEditor(DataTemplate inlineEditorTemplate)
            : <span class="kwrd">base</span>(inlineEditorTemplate)
        { }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Default constructor builds the default TextBox inline editor template.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="kwrd">public</span> TextBoxEditor()
        {
            FrameworkElementFactory textBox = <span class="kwrd">new</span> FrameworkElementFactory(<span class="kwrd">typeof</span>(TextBox));
            Binding binding = <span class="kwrd">new</span> Binding();
            binding.Path = <span class="kwrd">new</span> PropertyPath(<span class="str">"Value"</span>);
            binding.Mode = BindingMode.TwoWay;
            textBox.SetBinding(TextBox.TextProperty, binding);

            DataTemplate dt = <span class="kwrd">new</span> DataTemplate();
            dt.VisualTree = textBox;

            InlineEditorTemplate = dt;
        }
    }
}</pre>
</div>
<p> </p>
<h3>CultureInfoEditor</h3>
<p>My colleague <a href="http://www.sitechno.com/blog/" target="_blank">RJ</a> wrote inline editor CultureInfoEditor for TimePicker.Culture property, because the default editing experience for CultureInfo in Blend leads to invalid XAML. Below screenshot shows the CultureInfoEditor uses a ComboBox to display all CultureInfo and generates right XAML.</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image4.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="CultureInfoEditor" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb4.png" border="0" alt="CultureInfoEditor" width="644" height="398" /></a></p>
<p>CultureInfoEditor is a more complex example than TextBoxEditor, really shows how the underlying property is associated with editor via DataContext property.</p>
<p>CultureInfoEditor.cs:</p>
<div class="csharpcode-wrapper">
<pre class="csharpcode"><span class="rem">// (c) Copyright Microsoft Corporation.</span>
<span class="rem">// This source is subject to the Microsoft Public License (Ms-PL).</span>
<span class="rem">// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.</span>
<span class="rem">// All other rights reserved.</span>

<span class="kwrd">using</span> System.Reflection;
<span class="kwrd">using</span> Microsoft.Windows.Design.PropertyEditing;
<span class="kwrd">using</span> System.Globalization;
<span class="kwrd">using</span> System.ComponentModel;

<span class="kwrd">namespace</span> System.Windows.Controls.Input.Design
{
    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Editor for CultureInfo.</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="rem">/// &lt;remarks&gt;Currently does not support binding from xaml to the editor.&lt;/remarks&gt;</span>
    <span class="kwrd">public</span> <span class="kwrd">class</span> CultureInfoEditor : PropertyValueEditor
    {
        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// The ComboBox being used to edit the value.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="kwrd">private</span> ComboBox _owner;

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Preserve the constructor prototype from PropertyValueEditor.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="inlineEditorTemplate"&gt;Inline editor template.&lt;/param&gt;</span>
        <span class="kwrd">public</span> CultureInfoEditor(DataTemplate inlineEditorTemplate)
            : <span class="kwrd">base</span>(inlineEditorTemplate)
        { }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Default constructor builds a ComboBox inline editor template.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="kwrd">public</span> CultureInfoEditor()
        {
            <span class="rem">// not using databinding here because Silverlight does not support</span>
            <span class="rem">// the WPF CultureConverter that is used by Blend.</span>
            FrameworkElementFactory comboBox = <span class="kwrd">new</span> FrameworkElementFactory(<span class="kwrd">typeof</span>(ComboBox));
            comboBox.AddHandler(
                ComboBox.LoadedEvent,
                <span class="kwrd">new</span> RoutedEventHandler(
                    (sender, e) =&gt;
                    {
                        _owner = (ComboBox) sender;
                        _owner.SelectionChanged += EditorSelectionChanged;
                        INotifyPropertyChanged data = _owner.DataContext <span class="kwrd">as</span> INotifyPropertyChanged;
                        <span class="kwrd">if</span> (data != <span class="kwrd">null</span>)
                        {
                            data.PropertyChanged += DatacontextPropertyChanged;
                        }
                        _owner.DataContextChanged += CultureDatacontextChanged;
                    }));

            comboBox.SetValue(ComboBox.IsEditableProperty, <span class="kwrd">false</span>);
            comboBox.SetValue(ComboBox.DisplayMemberPathProperty, <span class="str">"DisplayName"</span>);
            comboBox.SetValue(ComboBox.ItemsSourceProperty, CultureInfo.GetCultures(CultureTypes.SpecificCultures));
            DataTemplate dt = <span class="kwrd">new</span> DataTemplate();
            dt.VisualTree = comboBox;

            InlineEditorTemplate = dt;
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Handles the SelectionChanged event of the owner control.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;</span>
        <span class="rem">/// &lt;param name="e"&gt;The &lt;see cref="System.Windows.Controls.SelectionChangedEventArgs"/&gt; </span>
        <span class="rem">/// instance containing the event data.&lt;/param&gt;</span>
        <span class="kwrd">private</span> <span class="kwrd">void</span> EditorSelectionChanged(<span class="kwrd">object</span> sender, SelectionChangedEventArgs e)
        {
            <span class="rem">// serialize with name.</span>
                <span class="kwrd">object</span> DataContext = _owner.DataContext;
                DataContext
                    .GetType()
                    .GetProperty(<span class="str">"Value"</span>, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty)
                    .SetValue(DataContext, ((CultureInfo)_owner.SelectedItem).Name, <span class="kwrd">new</span> <span class="kwrd">object</span>[] { });
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Handles the PropertyChanged event of the context object.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;</span>
        <span class="rem">/// &lt;param name="e"&gt;The &lt;see cref="System.ComponentModel.PropertyChangedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;</span>
        <span class="kwrd">private</span> <span class="kwrd">void</span> DatacontextPropertyChanged(<span class="kwrd">object</span> sender, PropertyChangedEventArgs e)
        {
            <span class="rem">// deserialize from name.</span>
            <span class="kwrd">if</span> (e.PropertyName == <span class="str">"Value"</span>)
            {
                <span class="kwrd">object</span> <span class="kwrd">value</span> = sender
                    .GetType()
                    .GetProperty(<span class="str">"Value"</span>, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty)
                    .GetValue(sender, <span class="kwrd">new</span> <span class="kwrd">object</span>[] { });

                <span class="kwrd">if</span> (<span class="kwrd">value</span> != <span class="kwrd">null</span>)
                {
                    <span class="kwrd">if</span> (<span class="kwrd">value</span> <span class="kwrd">is</span> <span class="kwrd">string</span>)
                    {
                        CultureInfo setCulture = <span class="kwrd">new</span> CultureInfo(<span class="kwrd">value</span>.ToString());
                        _owner.SelectedItem = setCulture;
                    }
                }
            }
        }

        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Called when the context is changed.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="sender"&gt;The sender.&lt;/param&gt;</span>
        <span class="rem">/// &lt;param name="e"&gt;The &lt;see cref="System.Windows.DependencyPropertyChangedEventArgs"/&gt; instance containing the event data.&lt;/param&gt;</span>
        <span class="kwrd">private</span> <span class="kwrd">void</span> CultureDatacontextChanged(<span class="kwrd">object</span> sender, DependencyPropertyChangedEventArgs e)
        {
            INotifyPropertyChanged old = e.OldValue <span class="kwrd">as</span> INotifyPropertyChanged;
            <span class="kwrd">if</span> (old != <span class="kwrd">null</span>)
            {
                old.PropertyChanged -= DatacontextPropertyChanged;
            }
            INotifyPropertyChanged newDataContext = e.NewValue <span class="kwrd">as</span> INotifyPropertyChanged;
            <span class="kwrd">if</span> (newDataContext != <span class="kwrd">null</span>)
            {
                newDataContext.PropertyChanged += DatacontextPropertyChanged;
            }
        }
    }
}</pre>
</div>
<p> </p>
<h3>ExpandableObjectConverter</h3>
<p>As discussed at the beginning, besides custom property value editors, sometimes you can use appropriate type converter to provide good editing experience and XAML serialization. One example is ColumnSeries.DependentRangeAxis: it is of IRangeAxis type, Blend doesn’t know how to edit it, so it shows DependentRangeAxis as read only in Properties Panel. By associating <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.expandableobjectconverter.aspx" target="_blank">ExpandableObjectConverter</a> to ColumnSeries.DependentRangeAxis:</p>
<div>
<pre class="csharpcode">b.AddCustomAttributes(
    Extensions.GetMemberName&lt;ColumnSeries&gt;(x =&gt; x.DependentRangeAxis),
    <span class="kwrd">new</span> TypeConverterAttribute(<span class="kwrd">typeof</span>(ExpandableObjectConverter)));
b.AddCustomAttributes(
    Extensions.GetMemberName&lt;ColumnSeries&gt;(x =&gt; x.IndependentAxis),
    <span class="kwrd">new</span> TypeConverterAttribute(<span class="kwrd">typeof</span>(ExpandableObjectConverter)));</pre>
</div>
<p>Blend displays a New button next to this property in Properties Panel; when clicked, it pops up the Select Object dialog, filtered with the property’s type IRangeAxis:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/04/image5.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ExpandableObjectConverter" src="http://www.ningzhang.org/wp-content/uploads/2009/04/image-thumb5.png" border="0" alt="ExpandableObjectConverter" width="644" height="399" /></a></p>
<p> </p>
<h3>Conclusion</h3>
<p>Blend and Silverlight together allow designers to create amazing UI against real controls directly, so it is very important that control developers take designer experience as part of overall control design and implementation. Having a custom property editor that provides nice editing UI and generates correct XAML is an important part of the designer experience. Hopefully this post helps you understand how to create custom property editors. Thanks!</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=Property%20Value%20Editors%20for%20Silverlight%20Controls&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;title=Property%20Value%20Editors%20for%20Silverlight%20Controls&amp;notes=This%20is%20part%20of%20the%20series%20on%20design%20time%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20discusses%20how%20to%20enhance%20property%20editing%20experience%20for%20Silverlight%20controls%20using%20property%20value%20editor%20and%20type%20converter.%20I%20will%20start%20with%20describing%20the%20overall%20property%20editing%20architecture%20in%20WPF%2FSilverlight%20designer%20extensibility%20framework%2C%20then%20use%20examples%20in%20%20Silverlight%20Toolkit%20March%202009%20Release%20to%20demonstrate%20how%20it%20is%20done%2C%20and%20unique%20issues%2Ftricks%20in%20Silverlight%20design%20time%20development." title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;t=Property%20Value%20Editors%20for%20Silverlight%20Controls" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;title=Property%20Value%20Editors%20for%20Silverlight%20Controls&amp;annotation=This%20is%20part%20of%20the%20series%20on%20design%20time%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20discusses%20how%20to%20enhance%20property%20editing%20experience%20for%20Silverlight%20controls%20using%20property%20value%20editor%20and%20type%20converter.%20I%20will%20start%20with%20describing%20the%20overall%20property%20editing%20architecture%20in%20WPF%2FSilverlight%20designer%20extensibility%20framework%2C%20then%20use%20examples%20in%20%20Silverlight%20Toolkit%20March%202009%20Release%20to%20demonstrate%20how%20it%20is%20done%2C%20and%20unique%20issues%2Ftricks%20in%20Silverlight%20design%20time%20development." title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;title=Property%20Value%20Editors%20for%20Silverlight%20Controls" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;t=Property%20Value%20Editors%20for%20Silverlight%20Controls&opener=bm&amp;ei=UTF-8&amp;d=This%20is%20part%20of%20the%20series%20on%20design%20time%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20discusses%20how%20to%20enhance%20property%20editing%20experience%20for%20Silverlight%20controls%20using%20property%20value%20editor%20and%20type%20converter.%20I%20will%20start%20with%20describing%20the%20overall%20property%20editing%20architecture%20in%20WPF%2FSilverlight%20designer%20extensibility%20framework%2C%20then%20use%20examples%20in%20%20Silverlight%20Toolkit%20March%202009%20Release%20to%20demonstrate%20how%20it%20is%20done%2C%20and%20unique%20issues%2Ftricks%20in%20Silverlight%20design%20time%20development." title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;t=Property%20Value%20Editors%20for%20Silverlight%20Controls" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F04%2F03%2Fproperty-value-editors-for-silverlight-controls%2F&amp;title=Property%20Value%20Editors%20for%20Silverlight%20Controls&amp;bodytext=This%20is%20part%20of%20the%20series%20on%20design%20time%20implementation%20in%20Silverlight%20Toolkit.%20This%20post%20discusses%20how%20to%20enhance%20property%20editing%20experience%20for%20Silverlight%20controls%20using%20property%20value%20editor%20and%20type%20converter.%20I%20will%20start%20with%20describing%20the%20overall%20property%20editing%20architecture%20in%20WPF%2FSilverlight%20designer%20extensibility%20framework%2C%20then%20use%20examples%20in%20%20Silverlight%20Toolkit%20March%202009%20Release%20to%20demonstrate%20how%20it%20is%20done%2C%20and%20unique%20issues%2Ftricks%20in%20Silverlight%20design%20time%20development." title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/Q34UqUjh5VQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/04/03/property-value-editors-for-silverlight-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/04/03/property-value-editors-for-silverlight-controls/</feedburner:origLink></item>
		<item>
		<title>How to Write Silverlight Design Time for All Designers: Visual Studio 2008, Blend 2; Blend 3, and Visual Studio 2010</title>
		<link>http://feedproxy.google.com/~r/NingZhangsBlog/~3/8cGmc6vtHnA/</link>
		<comments>http://www.ningzhang.org/2009/03/31/how-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 09:41:18 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[Design Time]]></category>
		<category><![CDATA[March 2009 Release]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/?p=284</guid>
		<description>This is part of the series on design time feature implementation in Silverlight. This post focuses on the breaking changes in designer extensibility framework introduced in Silverlight 3/Blend 3/Visual Studio 2010, and how to develop Silverlight design time to support all designers: Visual Studio 2008/Blend 2, and Visual Studio 2010/Blend 3.</description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>This is part of the series on design time implementation changes in <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>. This post focuses on the breaking changes in designer extensibility framework introduced in Silverlight 3/Blend 3/Visual Studio 2010, and how to develop Silverlight design time to support all designers: Visual Studio 2008/Blend 2, and Visual Studio 2010/Blend 3.</p>
<p> </p>
<h3>Silverlight 2 Design Time for Visual Studio 2008 and Blend 2</h3>
<p>Visual Studio and Blend share the same designer extensibility framework, and use it for both WPF and Silverlight. <a href="http://msdn.microsoft.com/en-us/library/bb546938.aspx" target="_blank">WPF Designer Extensibility</a> on MSDN is probably the best reference available for the designer extensibility framework. The <a href="http://www.codeplex.com/Silverlight/Release/ProjectReleases.aspx?ReleaseId=19172" target="_blank">December 2008 Release</a> of <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a> is based on Silverlight 2 (aka SL2), and has designer support for Visual Studio 2008 (aka VS9) and Blend 2. It is a good real world example in demonstrating how to develop Silverlight 2 design time features for VS9 and Blend 2. My blog post <a href="http://www.ningzhang.org/2008/12/28/design-time-feature-implementation-in-silverlight-toolkit/" target="_blank">Design Time Feature Implementation in Silverlight Toolkit</a> explains in detail how it is done, and the implementation framework readers can use in their own design time implementation.</p>
<p>To recap, the Silverlight 2 design time framework for Visual Studio 2008 and Blend 2 in a nutshell:</p>
<ul>
<li>MWD: the design time extensibility framework is exposed through a set of assemblies, most notably Microsoft.Windows.Design.dll, Microsoft.Windows.Design.Extensibility.dll, and Microsoft.Windows.Design.Interaction.dll. Collectively those assemblies are called MWD. They are installed under %DevEnvDir%\PublicAssemblies (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies in 32bit OS, or  C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies in 64bit OS). They are also GAC-ed. Most design time projects need to reference those MWD dlls. Visual Studio 2008 and Blend 2 use MWD version 3.5. <a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image34.png" target="_blank"><br />
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MWD in GAC" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb31.png" border="0" alt="MWD in GAC" width="600" height="233" /></a></li>
<li>Naming Convention: Visual Studio and Blend load design time assemblies using a naming convention: for control assembly Foo.dll, VS and Blend will find its design time assemblies with the name Foo.Design.dll, Foo.VisualStudio.Design.dll, and Foo.Expression.Design.dll, in the same directory where Foo.dll is, or the Design sub directory. Visual Studio will load Foo.Design.dll and Foo.VisualStudio.Design.dll, while Blend will load Foo.Design.dll and Foo.Expression.Design.dll. So it is advised to put design time features shared across all designers in .Design.dll, and put Visual Studio and Blend specific design time features in .VisualStudio.Design.dll and .Expression.Design.dll respectively.</li>
<li>Entry Point: when Visual Studio or Blend loads a design time assembly, it uses reflection to find all classes that implement <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.metadata.iregistermetadata.aspx" target="_blank">IRegisterMetadata</a>, and calls its only method <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.metadata.iregistermetadata.register.aspx" target="_blank">Register</a>. <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=19172" target="_blank">Silverlight Toolkit December 2008 Release</a> has a design time implementation framework detailed in previous blog post <a href="http://www.ningzhang.org/2008/12/28/design-time-feature-implementation-in-silverlight-toolkit/" target="_blank">Design Time Feature Implementation in Silverlight Toolkit</a>.</li>
</ul>
<p>Below screenshots of Silverlight.Controls.Design.sln in Silverlight 2 Toolkit source in <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a> demonstrates implementation of SL2 design time for VS9 and Blend 2 discussed above:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image35.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SL2 design projects" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb32.png" border="0" alt="SL2 design projects" width="644" height="460" /></a></p>
<p> </p>
<h3>What Changed In Silverlight 3, Blend 3 and Visual Studio 2010</h3>
<p>As stated in <a href="http://msdn.microsoft.com/en-us/library/bb514646.aspx" target="_blank">WPF Designer Extensibility Architecture</a> on MSDN:</p>
<blockquote><p>The WPF Designer supports the full extensibility framework. Expression Blend supports only property editors, metadata loading, and licensing. Blend does not support menu actions and adorners.</p></blockquote>
<p>Blend 2 has above limited support for Silverlight design time too, but Visual Studio 2008 has little support for Silverlight design time (just icons, metadata loading for few attributes like ToolboxBrowsableAttribute): it is more a viewer than a designer. To have WPF parity for Silverlight design time support, Blend 3 and Visual Studio 2010 (aka VS10) have to introduce breaking changes to the designer extensibility framework (i.e. MWD), most notably:</p>
<ul>
<li>MWD: most of the designer extensibility framework API stay the same, but their physical packaging changes: Microsoft.Windows.Design.dll is gone, and the version of all MWD assemblies changes from 3.5 to 4.0. Before Visual Studio 2010 Beta1, the only way to get the new MWD is via Blend 3 Preview, and its version is 3.7 instead of 4.0 for now:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image36.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MWD in Blend 3" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb33.png" border="0" alt="MWD in Blend 3" width="493" height="393" /></a></li>
<li>Entry Point: instead of reflect through <a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.metadata.iregistermetadata.aspx" target="_blank">IRegisterMetadata</a> implementations, Blend 3 and Visual Studio 2010 use a new assembly attribute ProvideMetadataAttribute, and the metadataProviderType must implement IProvideAttributeTable:<br />
<img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ProvideMetadataAttribute" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb34.png" border="0" alt="ProvideMetadataAttribute" width="600" height="389" /></li>
<li>Naming Convention: because of the breaking changes like MWD version and entry point, existing design time assemblies developed against 3.5 MWD will not load in Blend 3 and Visual Studio 2010, you have to write new design time against the new 4.0 MWD for Blend 3 and Visual Studio 2010. While this is OK for Blend (since you can only use Blend 3 with Silverlight 3 and Blend 2 with Silverlight 2), this creates a challenge for Visual Studio, since you can use Visual Studio 2008 for Silverlight 3 development, as well as Visual Studio 2010 for Silverlight 2 development.</li>
</ul>
<p>Below table lists all supported scenarios and which version of MWD is used to load design time assemblies:</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="77"><strong>SL\Designer</strong></td>
<td width="64"><strong>VS9</strong></td>
<td width="64"><strong>VS10</strong></td>
<td width="65"><strong>Blend2</strong></td>
<td width="65"><strong>Blend3</strong></td>
</tr>
<tr>
<td><strong>SL2</strong></td>
<td>MWD3.5</td>
<td>MWD4.0</td>
<td>MWD3.5</td>
<td> </td>
</tr>
<tr>
<td><strong>SL3</strong></td>
<td>MWD3.5</td>
<td>MWD4.0</td>
<td> </td>
<td>MWD4.0</td>
</tr>
</tbody>
</table>
<p>We can’t build one design time assembly against two incompatible MWDs, so we have to create two separate design time assemblies, one against each MWD. Design time assemblies are loaded by name, and we can’t have two assemblies with the same name in the same location, so the design time assembly loading mechanism (i.e., the naming convention) has to change, to allow multiple versions of the same design time assembly coexist.</p>
<p>While waiting for the new naming convention to come out with Blend 3 and Visual Studio 2010 RTM, we can do something clever now to support both VS9 and VS10. Remember current naming convention allows Visual Studio and Blend each to load two design assemblies:</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="182"><strong>DLL\Designer</strong></td>
<td width="104"><strong>Visual Studio</strong></td>
<td width="59"><strong>Blend</strong></td>
</tr>
<tr>
<td>Foo.Design.dll</td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td>Foo.VisualStudio.Design.dll</td>
<td>X</td>
<td> </td>
</tr>
<tr>
<td>Foo.Expression.Design.dll</td>
<td> </td>
<td>X</td>
</tr>
</tbody>
</table>
<p>so we can build the two assemblies against different versions of MWD:</p>
<ul>
<li>For Silverlight 3, we can have the shared .Design.dll build against MWD 4.0, so it can be loaded by both VS10 and Blend 3. We then have .VisualStudio.Design.dll build against MWD 3.5 and duplicate everything from shared .Design.dll, so it can be loaded by VS9. There is one minor issue though: we don’t have a place to put Visual Studio specific design time features for VS10, like using ToolboxBrowsableAttribute(false) to hide some controls from the increasingly crowded Visual Studio toolbox, since VS10 can’t load the .VisualStudio.Design.dll build against MWD 3.5. This will be solved with the new naming convention once Visual Studio 2010 RTM.</li>
</ul>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="182"><strong>DLL\MWD\Designer</strong></td>
<td width="59"><strong>MWD</strong></td>
<td width="46"><strong>VS9</strong></td>
<td width="53"><strong>VS10</strong></td>
<td width="66"><strong>Blend3</strong></td>
</tr>
<tr>
<td><strong>Foo.Design.dll</strong></td>
<td>4.0</td>
<td> </td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td><strong>Foo.VisualStudio.Design.dll</strong></td>
<td>3.5</td>
<td><strong>X</strong></td>
<td><strong>?</strong></td>
<td> </td>
</tr>
<tr>
<td><strong>Foo.Expression.Design.dll</strong></td>
<td>4.0</td>
<td> </td>
<td> </td>
<td>X</td>
</tr>
</tbody>
</table>
<ul>
<li>For Silverlight 2, follow the same approach: have the shared .Design.dll build against MWD 4.0, but have both .VisualStudio.Design.dll and .Expression.Design.dll build against MWD 3.5 and duplicate everything in shared .Design.dll. This way, both VS9 and Blend 2 will work just fine, but with the  same issue that there is no place to put Visual Studio specific features for VS10. Again, that will be solved with the new naming convention in VS10.</li>
</ul>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="182"><strong>DLL\MWD\Designer</strong></td>
<td width="64"><strong>MWD</strong></td>
<td width="64"><strong>VS9</strong></td>
<td width="64"><strong>VS10</strong></td>
<td width="64"><strong>Blend2</strong></td>
</tr>
<tr>
<td><strong>Foo.Design.dll</strong></td>
<td>4.0</td>
<td> </td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td><strong>Foo.VisualStudio.Design.dll</strong></td>
<td>3.5</td>
<td><strong>X</strong></td>
<td><strong>?</strong></td>
<td> </td>
</tr>
<tr>
<td><strong>Foo.Expression.Design.dll</strong></td>
<td>3.5</td>
<td> </td>
<td> </td>
<td>X</td>
</tr>
</tbody>
</table>
<p> </p>
<p> </p>
<h3>Design Time Feature Implementation in Silverlight 3 Toolkit</h3>
<h4>MWD</h4>
<p>The design projects in Silverlight 3 Toolkit in <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a> followed above mentioned scheme to support both Visual Studio 2008 and Visual Studio 2010, as well as Blend 3.</p>
<p>Download the <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=20430" target="_blank">March 2009 Release</a>, unzip the source code, load Silverlight.Controls.Design.sln into Visual Studio 2008. Use the simpler Control.Input.Design project as example:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image37.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Controls.Input.Design.csproj in Silverlight 3 Toolkit Source" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb35.png" border="0" alt="Controls.Input.Design.csproj in Silverlight 3 Toolkit Source" width="644" height="454" /></a></p>
<ul>
<li>Design projects for VS9/Blend3 need to reference the new 4.0 MWD. Here we use pre-build event to invoke CopySystemWindows.bat to locate Blend 3 and copy the two  MWD dlls to Binaries directory.</li>
<li>Please note the minor changes to CopySystemWindows.bat file: we need to quote “%THIS_DIR%\Binaries\Blend3” (lines in yellow) to handle cases where there is a space in the path to the directory the source code is unzipped to.</li>
</ul>
<p>If you don’t like the fragile CopySystemWindows.bat file or using build events, you can set Reference Paths to help Visual Studio find where the new MWD is, as shown below. The only caveat is that you need specify both %programfiles% and %programfiles(x86)% to make it build on both x86 and x64 machines.</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image38.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Controls.Input.Design.csproj in Silverlight 3 Toolkit Source" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb36.png" border="0" alt="Controls.Input.Design.csproj in Silverlight 3 Toolkit Source" width="644" height="457" /></a></p>
<p>The reference paths setting is persisted into the .csproj.user file:</p>
<blockquote><p>&lt;Project xmlns=&#8221;<a href="http://schemas.microsoft.com/developer/msbuild/2003&quot;">http://schemas.microsoft.com/developer/msbuild/2003&#8243;</a>&gt;<br />
  &lt;PropertyGroup&gt;<br />
    &lt;ReferencePath&gt;c:\Program Files\Microsoft Expression\Blend 3 Preview\;c:\Program Files (x86)\Microsoft Expression\Blend 3 Preview\&lt;/ReferencePath&gt;<br />
  &lt;/PropertyGroup&gt;<br />
&lt;/Project&gt;</p></blockquote>
<h4>Metadata.cs</h4>
<p>I use the same implementation framework as described in <a href="http://www.ningzhang.org/2008/12/28/design-time-feature-implementation-in-silverlight-toolkit/" target="_blank">Design Time Feature Implementation in Silverlight Toolkit</a>, with some minor changes:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image39.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Metadata.cs in Silverlight 3 Toolkit Source" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb37.png" border="0" alt="Metadata.cs in Silverlight 3 Toolkit Source" width="644" height="482" /></a></p>
<ul>
<li>I moved links to shared files Extensions.cs and MetadataBase.cs from Controls.Design.Common folder to under a solution folder with the same name;</li>
<li>Metadata.cs in .Design and .Expression.Design projects use the new entry point: use ProvideMetadata assembly attribute, and implement IProvideAttributeTable interface;</li>
<li>add note that everything in AddAttributes() method needs to be duplicated in corresponding .VisualStudio.Design project.</li>
</ul>
<p>The .VisualStudio.Design projects still use the old IRegisterMetadata interface in MWD 3.5, but:<br />
<a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image40.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb38.png" border="0" alt="image" width="644" height="482" /></a></p>
<ul>
<li>under Controls.Design folder are links to all *Metadata.cs files in corresponding .Design project;</li>
<li>AddAttributes() method duplicates the content of AddAttributes() method in corresponding .Design project.</li>
</ul>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2009/03/image41.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Controls.Input.Expression.Design.csproj in Silverlight 3 Toolkit Source" src="http://www.ningzhang.org/wp-content/uploads/2009/03/image-thumb39.png" border="0" alt="Controls.Input.Expression.Design.csproj in Silverlight 3 Toolkit Source" width="644" height="482" /></a></p>
<p> </p>
<h3>Conclusion</h3>
<p>While the breaking changes in MWD may cause some inconvenience, it is necessary to implement as rich a design time experience for Silverlight as for WPF. This post describes a way to handle the breaking changes and still support all existing designers: Visual Studio 2008, Blend 2, and Blend 3. Once Visual Studio 2010 is publicly available, I will blog about the new naming convention, and how Toolkit design time work in Visual Studio 2010. Stay tuned!</p>



Share and Enjoy:


	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;partner=sociable" title="Print"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010&amp;body=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F" title="email"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.ningzhang.org/feed/" title="RSS"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="" title="TwitThis"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;title=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010&amp;notes=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight.%20This%20post%20focuses%20on%20the%20breaking%20changes%20in%20designer%20extensibility%20framework%20introduced%20in%20Silverlight%203%2FBlend%203%2FVisual%20Studio%202010%2C%20and%20how%20to%20develop%20Silverlight%20design%20time%20to%20support%20all%20designers%3A%20Visual%20Studio%202008%2FBlend%202%2C%20and%20Visual%20Studio%202010%2FBlend%203." title="del.icio.us"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F" title="Technorati"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;t=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010" title="Facebook"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;title=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010&amp;annotation=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight.%20This%20post%20focuses%20on%20the%20breaking%20changes%20in%20designer%20extensibility%20framework%20introduced%20in%20Silverlight%203%2FBlend%203%2FVisual%20Studio%202010%2C%20and%20how%20to%20develop%20Silverlight%20design%20time%20to%20support%20all%20designers%3A%20Visual%20Studio%202008%2FBlend%202%2C%20and%20Visual%20Studio%202010%2FBlend%203." title="Google Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;title=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010" title="Live"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://bookmarks.yahoo.com/toolbar/savebm?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;t=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010&opener=bm&amp;ei=UTF-8&amp;d=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight.%20This%20post%20focuses%20on%20the%20breaking%20changes%20in%20designer%20extensibility%20framework%20introduced%20in%20Silverlight%203%2FBlend%203%2FVisual%20Studio%202010%2C%20and%20how%20to%20develop%20Silverlight%20design%20time%20to%20support%20all%20designers%3A%20Visual%20Studio%202008%2FBlend%202%2C%20and%20Visual%20Studio%202010%2FBlend%203." title="Yahoo! Bookmarks"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/yahoomyweb.png" title="Yahoo! Bookmarks" alt="Yahoo! Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;t=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010" title="MySpace"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ningzhang.org%2F2009%2F03%2F31%2Fhow-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010%2F&amp;title=How%20to%20Write%20Silverlight%20Design%20Time%20for%20All%20Designers%3A%20Visual%20Studio%202008%2C%20Blend%202%3B%20Blend%203%2C%20and%20Visual%20Studio%202010&amp;bodytext=This%20is%20part%20of%20the%20series%20on%20design%20time%20feature%20implementation%20in%20Silverlight.%20This%20post%20focuses%20on%20the%20breaking%20changes%20in%20designer%20extensibility%20framework%20introduced%20in%20Silverlight%203%2FBlend%203%2FVisual%20Studio%202010%2C%20and%20how%20to%20develop%20Silverlight%20design%20time%20to%20support%20all%20designers%3A%20Visual%20Studio%202008%2FBlend%202%2C%20and%20Visual%20Studio%202010%2FBlend%203." title="Digg"><img src="http://www.ningzhang.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>


<br/><br/><img src="http://feeds.feedburner.com/~r/NingZhangsBlog/~4/8cGmc6vtHnA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/03/31/how-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.ningzhang.org/2009/03/31/how-to-write-silverlight-design-time-for-all-designers-visual-studio-2008-blend-2-blend-3-and-visual-studio-2010/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 2.207 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-11-06 23:02:36 -->
