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

<channel>
	<title>Ning Zhang&#039;s Blog &#187; Silverlight</title>
	<atom:link href="http://www.ningzhang.org/category/sl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ningzhang.org</link>
	<description>About Silverlight, Microsoft technologies, and software development in general.</description>
	<lastBuildDate>Thu, 14 Apr 2011 22:47:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Silverlight 5 Beta Development Tools</title>
		<link>http://www.ningzhang.org/2011/04/14/silverlight-5-beta-development-tools/</link>
		<comments>http://www.ningzhang.org/2011/04/14/silverlight-5-beta-development-tools/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 22:47:00 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2011/04/14/silverlight-5-beta-development-tools/</guid>
		<description><![CDATA[Silverlight 5 Beta was announced at MIX11 yesterday. This blog post is an overview of Silverlight 5 development tools. To get started, download following components: Recommended Downloads Visual Studio 2010 SP1 (required) Silverlight 5 Beta Tools for Visual Studio SP1 (required) Expression Blend Preview for Silverlight 5(optional) &#160; VS/VWD 2010 SP1 + SL5Tools SL4 development [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.silverlight.net/getstarted/silverlight-5-beta/" target="_blank">Silverlight 5 Beta</a> was announced at MIX11 yesterday. This blog post is an overview of Silverlight 5 development tools. To get started, download following components:</p>
<blockquote><h5>Recommended Downloads</h5>
<ul>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=209902">Visual Studio 2010 SP1</a> (required) </li>
<li><a href="http://go.microsoft.com/fwlink/?LinkID=214309">Silverlight 5 Beta Tools for Visual Studio SP1</a> (required) </li>
<li><a href="http://go.microsoft.com/fwlink/?LinkId=215203">Expression Blend Preview for Silverlight 5</a>(optional) </li>
</ul>
</blockquote>
<p>&#160;</p>
<h2>VS/VWD 2010 SP1 + SL5Tools</h2>
<p>SL<strong>4</strong> development requires VS2010 or VWD2010 <strong>RTM</strong> and SL4Tools, and optionally Blend 4. VS2010 <strong>SP1</strong> has SL4 support built in, so SL4Tools is not needed if you’ve already upgraded to VS2010 SP1. SL<strong>5</strong> development requires VS2010 or VWD2010 <strong>SP1</strong> and SL5Tools, and optionally Blend Preview for Silverlight 5. </p>
<h3>Install</h3>
<p>SL5 Beta Tools installs Silverlight 5 Beta Developer Runtime, SDK, Update to VS2010 SP1 (KB2502836), and WCF RIA Services V1.0 SP2 Preview. </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image.png" target="_blank"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb.png" width="485" height="454" /></a></p>
<h3>Multi-targeting</h3>
<p>Once installed, you can create SL5 projects like you used to with previous versions of SL: </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image1.png" target="_blank"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb1.png" width="524" height="420" /></a></p>
<p>SL5 projects can reference assemblies built against early versions of Silverlight. Below screenshot shows a SL5 project using SL4 SDK via Project-&gt;Add Reference…–&gt;Browse:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image2.png" target="_blank"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb2.png" width="604" height="428" /></a></p>
<p>And the result in .csproj file: </p>
<blockquote><p>&lt;Reference Include=&quot;System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL&quot;&gt;      <br />&#160; &lt;SpecificVersion&gt;False&lt;/SpecificVersion&gt;       <br />&#160; &lt;HintPath&gt;..\..\..\..\..\..\..\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\System.Windows.Controls.dll&lt;/HintPath&gt;       <br />&lt;/Reference&gt;       </p>
</blockquote>
<p>Please notice the HintPath and assembly version (Btw, SL5 increased assembly version from 2.0.5.0 to 5.0.5.0).</p>
<p>You can also upgrade existing SL4 projects to target SL5: </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image3.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb3.png" width="597" height="454" /></a></p>
<p>The upgrade changes &lt;ProjectGuid&gt; and &lt;TargetFrameworkVersion&gt; in .csproj, as well as upgrading all SDK references to SL5’s. </p>
<h3>Binding Debugging</h3>
<p>A popular new feature in SL5Tools is xaml binding debugging: </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image4.png" target="_blank"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb4.png" width="604" height="428" /></a></p>
<p>&#160;</p>
<h2>Blend Preview for Silverlight 5</h2>
<p>Optionally, you can also install Blend Preview for Silverlight 5, which is basically Blend 4 with SL5 support:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image5.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb5.png" width="604" height="454" /></a></p>
<p>And you can use both VS and Blend on the same SL5 project and switch between them:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image6.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb6.png" width="604" height="454" /></a></p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image7.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb7.png" width="604" height="428" /></a></p>
<p>&#160;</p>
<h2>Troubleshoot &amp; Uninstall</h2>
<p>VS2010 SP1, SL5Tools and Blend Preview install all take a long time, so please be patient. If you run into install issues, you may want to take a look at install logs in %temp% directory, and attach those logs when you report install issues to Microsoft:</p>
<blockquote><p>C:\Users\ningz\AppData\Local\Temp&gt;dir /b /o-d *silver*      <br />Silverlight 5 Beta Tools for Visual Studio 2010 SP1_20110413_220121704.html       <br />Silverlight 5 Beta Tools for Visual Studio 2010 SP1_20110413_220121704-MSI_RiaServices.msi.txt       <br />Silverlight 5 Beta Tools for Visual Studio 2010 SP1_20110413_220121704-MSI_silverlight_sdk.msi.txt       <br />Silverlight0.log       </p>
</blockquote>
<p>To uninstall Silverlight 5 tools, use control panel to uninstall each component individually:</p>
<ul>
<li>SL5 runtime, SDK, RIA Services, Blend Preview </li>
</ul>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image8.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb8.png" width="604" height="291" /></a></p>
<ul>
<li>And Update to VS2010 (KB2502836) (please click “View installed updates” to see below) </li>
</ul>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2011/04/image9.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2011/04/image_thumb9.png" width="604" height="256" /></a></p>
<p>&#160;</p>
<p>Enjoy developing against Silverlight 5!</p>
<p>&#160;</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:4df63783-e095-4b42-8016-c3c44cdf4809" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Silverlight+5" rel="tag">Silverlight 5</a>,<a href="http://technorati.com/tags/Visual+Studio" rel="tag">Visual Studio</a>,<a href="http://technorati.com/tags/Blend" rel="tag">Blend</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2011/04/14/silverlight-5-beta-development-tools/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Touch Support in Silverlight</title>
		<link>http://www.ningzhang.org/2010/10/08/touch-support-in-silverlight/</link>
		<comments>http://www.ningzhang.org/2010/10/08/touch-support-in-silverlight/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 10:44:23 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Manipulation]]></category>
		<category><![CDATA[Touch]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2010/10/08/touch-support-in-silverlight/</guid>
		<description><![CDATA[This post is a modification of MSDN articles Multitouch Input and Gesture Support for Windows Phone, as a quick overview and reference for myself on Silverlight touch support. &#160; Overview Below class diagram shows key classes for Silverlight touch support: Touch Touch events are asynchronous. Touch events are always fired via application level Touch.FrameReported event. [...]]]></description>
			<content:encoded><![CDATA[<p>This post is a modification of MSDN articles <a href="http://msdn.microsoft.com/en-us/library/dd894494(VS.95).aspx" target="_blank">Multitouch Input</a> and <a href="http://msdn.microsoft.com/en-us/library/ff967546(VS.92).aspx" target="_blank">Gesture Support for Windows Phone</a>, as a quick overview and reference for myself on Silverlight touch support.</p>
<p>&#160;</p>
<h4>Overview</h4>
<p>Below class diagram shows key classes for Silverlight touch support:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/10/SLTouch.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Silverlight Touch Class Diagram" border="0" alt="Silverlight Touch Class Diagram" src="http://www.ningzhang.org/wp-content/uploads/2010/10/SLTouch_thumb.png" width="604" height="726" /></a></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/dd728833(v=VS.95).aspx" target="_blank">Touch</a>
<ul>
<li>Touch events are asynchronous. </li>
<li>Touch events are always fired via application level <a href="http://msdn.microsoft.com/en-us/library/dd728833(v=VS.95).aspx" target="_blank">Touch</a>.<a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touch.framereported(VS.95).aspx" target="_blank">FrameReported</a> event. </li>
<li>Since touch events are global, they are direct, and there is no need for touch capture. </li>
<li>Multitouch is supported. </li>
</ul>
</li>
<li>Manipulation
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.input.manipulation.aspx" target="_blank">Manipulation</a> events are exposed by UIElement. They are routed events. </li>
<li>Manipulation events are always fired, IsManipulationEnabled property isn’t supported. </li>
<li>Manipulation events are synchronous. </li>
<li>Only translation and expansion are supported, rotation is not. </li>
<li>Concurrent multiple manipulations are not supported. </li>
<li>Gesture isn’t supported directly. It is supported by <a href="http://msdn.microsoft.com/en-us/library/ff434208.aspx" target="_blank">XNA</a> and <a href="http://blogs.msdn.com/b/delay/archive/2010/09/16/pining-for-windows-phone-7-controls-we-got-ya-covered-announcing-the-first-release-of-the-silverlight-for-windows-phone-toolkit.aspx" target="_blank">Silverlight for Windows Phone Toolkit</a>. </li>
</ul>
</li>
<li>Controls: on Windows Phone 7, ScrollViewer supports pan &amp; flick, Button supports tab. </li>
</ul>
<h4>Silverlight 3</h4>
<h5>Platform Requirements</h5>
<p>Multitouch requires an environment (device; platform and operating system; hosting application such as a browser) that can propagate the touch input to an individual application, such as your Silverlight-based application.</p>
<p>Windows 7 supports multitouch input at the operating system level. This is supported in part through a message (<a href="http://msdn.microsoft.com/en-us/library/dd317341(VS.85).aspx" target="_blank">WM_TOUCH</a>). Already at this level, the operating system provides a promotion of multitouch messages to mouse messages. The promotion is present so that multitouch users can use touch and gestures to substitute as mouse moves or mouse clicks. This is useful when interacting with applications that may not be touch-aware, and the application does all its spatial input processing through mouse events and messages. Windows 7 also coalesces the messages when appropriate, so that applications do not have to process an overflow of intermediate messages that all generate incremental events.</p>
<p>Internet Explorer version 8 as a browser host is also multitouch aware. Internet Explorer version 8 forwards platform multitouch messages to plug-ins such as Silverlight that are running within Internet Explorer, such that Silverlight applications can interact with multitouch input.</p>
<p>Multitouch Input for Silverlight (shown for IE8 host)</p>
<p><img title="Multitouch Input and Platform Input in Silverlight" alt="Multitouch Input and Platform Input in Silverlight" src="http://i.msdn.microsoft.com/dynimg/IC303288.png" /></p>
<p>Multitouch is also supported for Silverlight in current versions of Firefox hosts running on Windows 7, and for out-of-browser applications running on Windows 7. However, multitouch input is not supported for applications running in <a href="http://msdn.microsoft.com/en-us/library/cc189023(v=VS.95).aspx">full-screen</a> mode.</p>
<h5>Registering for Multitouch</h5>
<p>As part of the broader platform architecture for multitouch, each application that wants to receive multitouch messages must register its HWND (Touch API for Windows 7 includes <a href="http://msdn.microsoft.com/en-us/library/dd317326(VS.85).aspx" target="_blank">RegisterTouchWindow</a> for this purpose). The Silverlight 4 run time takes care of this registration step, and registers Silverlight as a runtime and all applications that use Silverlight as the runtime. Therefore it is not generally necessary to interact directly with platform code to process multitouch input. However, the characteristics of multitouch interaction within Touch API for Windows 7 and Silverlight 4 multitouch are fairly specific:</p>
<ul>
<li>
<p>Silverlight 4 is registered for raw touch input, not gestures. If your requirements include gestures, you have to process touch input into gestures using your own application code, within the context of Silverlight. Alternatively, you may need a larger interoperation design so that you can include a separate HWND that is multitouch registered for gestures from the platform, and interoperates with a Silverlight content area.</p>
</li>
<li>
<p>In general, Silverlight 4 promotes raw touch input to mouse events. (However, on a per-touchframe basis, you can disable promotion, as is described in upcoming sections of this topic.)</p>
</li>
<li>
<p>Within a host, certain gestures might be promoted by the browser host to become events other than mousedown/mousemove/mouseup.</p>
</li>
</ul>
<h5>Promotion to Mouse Events</h5>
<p>Mouse event promotion exists so that multitouch users can use touch and gestures to substitute as mouse moves or mouse clicks. Conceptually this is the default, because applications that predate or do not consider multitouch would not know what API to call to perform the promotion, and therefore the platform does the mouse promotion in most cases. Silverlight 4 perpetuates the general concept of mouse event promotion for much the same reasons. Any given existing Silverlight control might have handlers for mouse events, but not specifically for multitouch events. For example, a button would be expected to act as if clicked when the user used a multitouch device to interact with it.</p>
<p>Mouse event promotion does have the potential for event dualism in cases where there is deliberate handling of a multitouch frame and its touch points. Within the body of the handler for a Silverlight multitouch event, you can suspend mouse event promotion for the duration of the primary touch down. For example, if you wanted to create a touch-aware button that performed different actions based on the touch characteristics, you could suspend the promotion so that your button did not promote to the usual &quot;click&quot; behavior, and instead went to your discrete logic for how to handle the input. To do this, call <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventargs.suspendmousepromotionuntiltouchup(v=VS.95).aspx">SuspendMousePromotionUntilTouchUp</a> as one of the first operations of your handler.</p>
<p>The exact nature of mouse promotion is not documented here, because it is a platform characteristic. Generally speaking, the mechanism is a message-to-message promotion.</p>
<h5>Touch to Gesture</h5>
<p>Silverlight processes multitouch messages at the level of the raw message, analogous to the platform WM_TOUCH, along with access to other APIs that can capture touchpoint characteristics at that raw level that are then exposed as Silverlight APIs. Silverlight does not natively process touch to gestures, use the platform capabilities to that effect, or process <a href="http://msdn.microsoft.com/en-us/library/dd353242(VS.85).aspx" target="_blank">WM_GESTURE</a>. (Processing WM_GESTURE would require a registration state with the platform that Silverlight 4 does not opt into.)</p>
<p>If you want to process multitouch using the gesture metaphor, your code must handle the touch events and use the API exposed under Silverlight 4 and process into gestures, with or without using the platform API for gestures. This is not trivial.</p>
<h5>Touch API</h5>
<p>One important difference between multitouch input and other input techniques supported in Silverlight (mouse, keyboard, stylus) is that you register for multitouch events on an application-wide basis, not by adding handlers to specific input elements (<a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement(v=VS.95).aspx">UIElement</a> objects). This is consistent with the metaphor that Silverlight as a whole is the &quot;application&quot; registered with the platform.</p>
<ul>
<li>
<p>To assign a multitouch event handler, you assign a handler for the static event <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touch.framereported(v=VS.95).aspx">Touch.FrameReported</a>. <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touch(v=VS.95).aspx">System.Windows.Input.Touch</a> is a static service class that exists solely for this purpose with <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touch.framereported(v=VS.95).aspx">Touch.FrameReported</a> as its only API.</p>
</li>
<li>
<p>The handler you write for <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touch.framereported(v=VS.95).aspx">Touch.FrameReported</a> is based on the <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventhandler(v=VS.95).aspx">TouchFrameEventHandler</a> delegate.</p>
</li>
<li>
<p>In a typical UI design, you might have areas of the UI that you intend to support specific multitouch actions within, and other areas where it would be better to use mouse promotion and not necessarily process the input as multitouch. To determine where the primary touch point is, you may have to evaluate the overall coordinate against the location of your multitouch-aware element, and its bounds. See <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventargs.getprimarytouchpoint(v=VS.95).aspx">GetPrimaryTouchPoint</a> for more information and example code.</p>
</li>
<li>
<p>As mentioned previously, you may want to suspend mouse event promotion as part of your <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventhandler(v=VS.95).aspx">TouchFrameEventHandler</a> logic. To do this, call <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventargs.suspendmousepromotionuntiltouchup(v=VS.95).aspx">SuspendMousePromotionUntilTouchUp</a> as one of the first operations.</p>
</li>
<li>
<p>Touch messages as reported to Silverlight 4 are typically combined as frames, which start with a primary &quot;down&quot; touch point. Sometimes you are only interested in the first touch point and the first &quot;up&quot; But the frame may contain other touch points and &quot;move&quot; actions. To access the full collection of points in a frame in your handlers, call <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventargs.gettouchpoints(v=VS.95).aspx">GetTouchPoints</a>. For a given touch point, probably the most important information is its <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchpoint.position(v=VS.95).aspx">Position</a>.</p>
</li>
<li>
<p>Other APIs expose information that in the platform API would be found in the TOUCHINPUT structure. Examples of such API are:<a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchframeeventargs.timestamp(v=VS.95).aspx">TouchFrameEventArgs.Timestamp</a>; <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchdevice.directlyover(v=VS.95).aspx">TouchDevice.DirectlyOver</a>; <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchpoint.size(v=VS.95).aspx">TouchPoint.Size</a>; <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.touchpoint.touchdevice(v=VS.95).aspx">TouchPoint.TouchDevice</a>. Depending on your scenario, you might not always need this level of information.</p>
</li>
</ul>
<h5>Manipulation API in Silverlight Version 4</h5>
<p>The Silverlight 4 <a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement(v=VS.95).aspx">UIElement</a> class has several events related to manipulations, as well as event support classes such as <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.manipulationstartedeventargs(v=VS.95).aspx">ManipulationStartedEventArgs</a>. However, these APIs and the related manipulation concepts do not have full support under Silverlight 4 at run time. To handle these events, your application must be targeting Silverlight for Windows Phone. The events exist in the Silverlight 4 assemblies in order to provide common designer support for both Silverlight 4 and Silverlight for Windows Phone.</p>
<p>&#160;</p>
<h4>
<ul>Silverlight for Windows Phone 7</ul>
</h4>
<h5>Gesture Support in the Silverlight Framework</h5>
<p>For a full list of supported Windows Phone Silverlight gestures, see the <a href="http://go.microsoft.com/fwlink/?LinkID=183218">UI Design and Interaction Guide</a>.</p>
<p>Silverlight for Windows Phone allows you to process touch input by using manipulation events. By using these events, you can move and scale objects in response to touch and multi-touch input. The events are described in the following table.</p>
<p><span style="text-align: ; widows: 2; text-transform: none; text-indent: 0px; letter-spacing: normal; border-collapse: separate; white-space: normal; orphans: 2; color: ; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><span style="text-align: left; font-family: ; font-size: " class="Apple-style-span"></span><br />
<table style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; background-color: transparent; width: ; border-collapse: collapse; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; word-spacing: normal" width="591">
<tbody>
<tr style="vertical-align: top">
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="143" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Event</font></p>
</th>
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="446" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Description</font></p>
</th>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="143">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">ManipulationStarted</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="446">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">This event occurs when the user starts a direct manipulation by placing their finger or fingers on the screen.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="143">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">ManipulationDelta</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="446">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">This event occurs repeatedly while the user is moving their finger or fingers on the screen.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="143">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">ManipulationCompleted</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="446">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">This event occurs when the user removed their finger or fingers from the screen</font></p>
</td>
</tr>
</tbody>
</table>
<p>   </span></p>
<p><img title="Note" alt="Note" src="http://i.msdn.microsoft.com/Hash/030c41d9079671d09a62d8e2c1db6973.gif" /><strong>Note:</strong></p>
<p>Silverlight controls that are supported on Windows Phone are gesture-aware, and support gestures such as tap, pan, and flick. You can handle simple gestures such as tap, double-tap, and tap-and-hold by using mouse events. For more information, see the <a href="http://go.microsoft.com/fwlink/?LinkId=200842">Input for Windows Phone</a> topic.</p>
<p>&#160;</p>
<h5>Gesture Support in the XNA Framework</h5>
<p>The XNA framework offers a robust touch gesture system for developing applications. Developers can leverage this built-in gesture system instead of implementing one from scratch. The following XNA gestures are supported in Windows Phone.</p>
<p><span style="text-align: ; widows: 2; text-transform: none; text-indent: 0px; letter-spacing: normal; border-collapse: separate; white-space: normal; orphans: 2; color: ; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span"><span style="text-align: left; font-family: ; font-size: " class="Apple-style-span"></span><br />
<table style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; background-color: transparent; width: ; border-collapse: collapse; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; word-spacing: normal" width="575">
<tbody>
<tr style="vertical-align: top">
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="82" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">GestureType</font></p>
</th>
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="491" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Description</font></p>
</th>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Tap</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">A finger touches the screen and releases.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">DoubleTap</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">This gesture represents two taps in succession.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Hold</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">A finger touches the screen and holds it in place for a brief period of time.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">FreeDrag</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">A finger touches the screen and moves in any direction.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">VerticalDrag</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">A finger touches the screen and moves in an up or down direction.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">HorizontalDrag</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">A finger touches the screen and moves in a left or right direction.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">DragComplete</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Marks the end of a FreeDrag, VerticalDrag, or HorizontalDrag gesture.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Flick</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">A finger drags across the screen and is lifted up without stopping.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Pinch</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Two fingers press on the screen and move around.</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="82">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">PinchComplete</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="491">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">This gesture marks the end of a Pinch gesture.</font></p>
</td>
</tr>
</tbody>
</table>
<p>   </span></p>
<p>The following list provides useful topics and articles for implementing gesture support in an XNA application:</p>
<ul>
<li>
<p><a href="http://go.microsoft.com/fwlink/?LinkId=200843">Working with Touch Input (Windows Phone)</a></p>
</li>
<li>
<p><a href="http://go.microsoft.com/fwlink/?LinkId=200844">Detecting Gestures on a Multi-touch Screen (Windows Phone)</a></p>
</li>
<li>
<p><a href="http://go.microsoft.com/fwlink/?LinkId=200845">Windows Phone 7 Gestures Compared</a></p>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2010/10/08/touch-support-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Silverlight Animation Class Diagram</title>
		<link>http://www.ningzhang.org/2010/10/03/silverlight-animation-class-diagram/</link>
		<comments>http://www.ningzhang.org/2010/10/03/silverlight-animation-class-diagram/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 05:16:57 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[animation]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2010/10/03/silverlight-animation-class-diagram/</guid>
		<description><![CDATA[The MSDN section Animation is a good overview on Silverlight animation. Below class diagram, summary and table can serve as quick reference. Diagram Summary Timeline is the base class of animation classes and Storyboard. It provides BeginTime, Duration, FillBehavior, RepeatBehavior, AutoReverse etc. dependent properties, and Completed event. Storyboard is a collection of Timelines, including animations [...]]]></description>
			<content:encoded><![CDATA[<p>The MSDN section <a href="http://msdn.microsoft.com/en-us/library/cc189090(v=VS.95).aspx">Animation</a> is a good overview on Silverlight animation. Below class diagram, summary and table can serve as quick reference.</p>
<p><strong><font size="2">Diagram</font></strong></p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/10/Animation.png" target="_blank"><img style="background-image: none; border-right-width: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Silverlight Animation Class Diagram" border="0" alt="Silverlight Animation Class Diagram" src="http://www.ningzhang.org/wp-content/uploads/2010/10/Animation_thumb.png" width="604" height="278" /></a></p>
<p><strong><font size="2">Summary</font></strong></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline(VS.95).aspx" target="_blank">Timeline</a> is the base class of animation classes and Storyboard. It provides <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.begintime(v=VS.95).aspx" target="_blank">BeginTime</a>, <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.duration(v=VS.95).aspx" target="_blank">Duration</a>, <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.fillbehavior(v=VS.95).aspx" target="_blank">FillBehavior</a>, <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.repeatbehavior(v=VS.95).aspx" target="_blank">RepeatBehavior</a>, <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.autoreverse(v=VS.95).aspx" target="_blank">AutoReverse</a> etc. dependent properties, and <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.timeline.completed(v=VS.95).aspx" target="_blank">Completed</a> event. </li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.storyboard(v=VS.95).aspx" target="_blank">Storyboard</a> is a collection of Timelines, including animations and storyboards. It provides <a href="http://msdn.microsoft.com/en-us/library/cc190590(v=VS.95).aspx" target="_blank">Begin</a>, <a href="http://msdn.microsoft.com/en-us/library/cc190749(v=VS.95).aspx" target="_blank">Stop</a>, <a href="http://msdn.microsoft.com/en-us/library/cc190455(v=VS.95).aspx" target="_blank">Pause</a>, <a href="http://msdn.microsoft.com/en-us/library/cc190437(v=VS.95).aspx" target="_blank">Resume</a> etc. methods, and <a href="http://msdn.microsoft.com/en-us/library/cc190580(v=VS.95).aspx" target="_blank">TargetName</a> and <a href="http://msdn.microsoft.com/en-us/library/cc672995(v=VS.95).aspx" target="_blank">TargetProperty</a> attached properties. </li>
<li>Basic animations: [<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimation(v=VS.95).aspx" target="_blank">Double</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.pointanimation(v=VS.95).aspx" target="_blank">Point</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.coloranimation(v=VS.95).aspx" target="_blank">Color</a>]Animation classes animate correspondingly typed dependent properties between two values specified by From, To, By properties. They use EasingFunction property to animate changes non-linearly:
<ul>
<li>Easing functions: Silverlight provides 11 easing function classes ([<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.backease(v=VS.95).aspx" target="_blank">Back</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.bounceease(v=VS.95).aspx" target="_blank">Bounce</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.circleease(v=VS.95).aspx" target="_blank">Circle</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.cubicease(v=VS.95).aspx" target="_blank">Cubic</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.elasticease(v=VS.95).aspx" target="_blank">Elastic</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.exponentialease(v=VS.95).aspx" target="_blank">Exponential</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.powerease(v=VS.95).aspx" target="_blank">Power</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.quadraticease(v=VS.95).aspx" target="_blank">Quadratic</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.quarticease(v=VS.95).aspx" target="_blank">Quartic</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.quinticease(v=VS.95).aspx" target="_blank">Quintic</a>|<a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.sineease(v=VS.95).aspx" target="_blank">Sine</a>]Ease), all subclass of <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.easingfunctionbase(v=VS.95).aspx" target="_blank">EasingFunctionBase</a>, which provides dependent property <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.easingfunctionbase.easingmode(v=VS.95).aspx" target="_blank">EasingMode</a>.&#160; </li>
</ul>
</li>
<li>Key-frame animation: key-frame animations support animating through a collection of key frames, each with KeyTime and Value properties. They also support multiple interpolation methods between key frames: discrete, easing, linear, spline. So there are 13 key frame classes: [Discrete|Easing|Linear|Spline][Double|Point|Color]KeyFrame and <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.objectkeyframe(v=VS.95).aspx" target="_blank">ObjectKeyFrame</a>. </li>
</ul>
<p><strong><font size="2">Table</font></strong></p>
<table style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; background-color: transparent; width: ; border-collapse: collapse; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; word-spacing: normal" width="596">
<tbody>
<tr style="vertical-align: top">
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="63" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Property type</font></p>
</th>
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="98" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Basic (From/To/By) animation</font></p>
</th>
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="190" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Key-frame animation</font></p>
</th>
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="187" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Usage example</font></p>
</th>
<th style="border-bottom: rgb(187,187,187) 1px solid; text-align: ; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; background-color: rgb(229,229,229); font-style: ; padding-left: 4px; padding-right: 4px; font-family: ; height: ; color: ; font-size: ; border-top: rgb(187,187,187) 1px solid; font-weight: ; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="10" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Interpolation methods supported</font></p>
</th>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="64">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.color(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">Color</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="98">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.coloranimation(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">ColorAnimation</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="190">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.coloranimationusingkeyframes(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">ColorAnimation-UsingKeyFrames</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="187">
<p><font face="Segoe UI"></font><font size="2"></font><font color="#000000"></font><font style="font-size: ">Animate the<span class="Apple-converted-space">&#160;</span></font><font style="font-size: "><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.color(v=VS.95).aspx"><font color="#1364c4">Color</font></a></span></font><font color="#000000"><span class="Apple-converted-space">&#160;</span>of a<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.solidcolorbrush(v=VS.95).aspx"><font color="#1364c4">SolidColorBrush</font></a></span><font color="#000000"><span class="Apple-converted-space">&#160;</span>or a<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.gradientstop(v=VS.95).aspx"><font color="#1364c4">GradientStop</font></a></span><font color="#000000">.</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; font-family: ; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="10" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Discrete, Linear, Splined</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="64">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.double(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">Double</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="98">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimation(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">DoubleAnimation</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="190">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.doubleanimationusingkeyframes(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">DoubleAnimation-UsingKeyFrames</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="187">
<p><font face="Segoe UI"></font><font size="2"></font><font color="#000000"></font><font style="font-size: ">Animate the<span class="Apple-converted-space">&#160;</span></font><font style="font-size: "><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.width(v=VS.95).aspx"><font color="#1364c4">Width</font></a></span></font><font color="#000000"><span class="Apple-converted-space">&#160;</span>of a<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.shapes.rectangle(v=VS.95).aspx"><font color="#1364c4">Rectangle</font></a></span><font color="#000000"><span class="Apple-converted-space">&#160;</span>or the<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.height(v=VS.95).aspx"><font color="#1364c4">Height</font></a></span><font color="#000000"><span class="Apple-converted-space">&#160;</span>of an<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.shapes.ellipse(v=VS.95).aspx"><font color="#1364c4">Ellipse</font></a></span><font color="#000000"><span class="Apple-converted-space">&#160;</span>(or any </font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement(v=VS.95).aspx"><font color="#1364c4">FrameworkElement</font></a></span><font color="#000000">)</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; font-family: ; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="10" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Discrete, Linear, Splined</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="64">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.point(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">Point</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="98">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.pointanimation(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">PointAnimation</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="190">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.pointanimationusingkeyframes(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">PointAnimation-UsingKeyFrames</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="187">
<p><font face="Segoe UI"></font><font size="2"></font><font color="#000000"></font><font style="font-size: ">Animate the<span class="Apple-converted-space">&#160;</span></font><font style="font-size: "><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.ellipsegeometry.center(v=VS.95).aspx"><font color="#1364c4">Center</font></a></span></font><font color="#000000"><span class="Apple-converted-space">&#160;</span>position of an<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.ellipsegeometry(v=VS.95).aspx"><font color="#1364c4">EllipseGeometry</font></a></span><font color="#000000">.</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; font-family: ; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="10" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Discrete, Linear, Splined</font></p>
</td>
</tr>
<tr style="vertical-align: top">
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="64">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.object(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">Object</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="98">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">None</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="190">
<p><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.animation.objectanimationusingkeyframes(v=VS.95).aspx"><font face="Segoe UI"></font><font style="font-size: " color="#1364c4" size="2">ObjectAnimation-UsingKeyFrames</font></a></span></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; line-height: 18px; background-color: rgb(255,255,255); margin: 1px; padding-left: 4px; padding-right: 4px; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" width="187">
<p><font face="Segoe UI"></font><font size="2"></font><font color="#000000"></font><font style="font-size: ">Animate the<span class="Apple-converted-space">&#160;</span></font><font style="font-size: "><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.shapes.shape.fill(v=VS.95).aspx"><font color="#1364c4">Fill</font></a></span></font><font color="#000000"><span class="Apple-converted-space">&#160;</span>property from one<span class="Apple-converted-space">&#160;</span></font><span><a style="color: ; text-decoration: " href="http://msdn.microsoft.com/en-us/library/system.windows.media.gradientbrush(v=VS.95).aspx"><font color="#1364c4">GradientBrush</font></a></span><font color="#000000"><span class="Apple-converted-space">&#160;</span>to another.</font></p>
</td>
<td style="border-bottom: rgb(187,187,187) 1px solid; border-left: rgb(187,187,187) 1px solid; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; font-family: ; border-top: rgb(187,187,187) 1px solid; border-right: rgb(187,187,187) 1px solid; padding-top: 4px" height="21" width="10" align="left">
<p><font face="Segoe UI"></font><font style="font-size: " color="#000000" size="2">Discrete</font></p>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2010/10/03/silverlight-animation-class-diagram/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Fix WP7 Dev Tools Install Issue: Setup cannot be run in Program Compatibility Mode</title>
		<link>http://www.ningzhang.org/2010/10/03/fix-wp7-dev-tools-install-issue-setup-cannot-be-run-in-program-compatibility-mode/</link>
		<comments>http://www.ningzhang.org/2010/10/03/fix-wp7-dev-tools-install-issue-setup-cannot-be-run-in-program-compatibility-mode/#comments</comments>
		<pubDate>Sun, 03 Oct 2010 22:59:31 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2010/10/03/fix-wp7-dev-tools-install-issue-setup-cannot-be-run-in-program-compatibility-mode/</guid>
		<description><![CDATA[I had VS2010 running while installing developer tools for Windows Phone 7, so I had to exit setup, close VS2010, and rerun vm_web.exe. But it gave following error: Visual Studio setup cannot run in compatibility mode. For more information see the &#8216;Installing&#8217; section in the Visual Studio Readme at &#34;http://go.microsoft.com/fwlink/?LinkId=143397&#34;. After searching the Internet and [...]]]></description>
			<content:encoded><![CDATA[<p>I had VS2010 running while installing <a href="http://developer.windowsphone.com/windows-phone-7/" target="_blank">developer tools for Windows Phone 7</a>, so I had to exit setup, close VS2010, and rerun vm_web.exe. But it gave following error:</p>
<blockquote><p>Visual Studio setup cannot run in compatibility mode. For more information see the &#8216;Installing&#8217; section in the Visual Studio Readme at &quot;<a href="http://go.microsoft.com/fwlink/?LinkId=143397%22">http://go.microsoft.com/fwlink/?LinkId=143397&quot;</a>.</p>
</blockquote>
<p>After searching the Internet and tried a few things, what worked for me is to <strong>un</strong>check “Run this program in compatibility mode” in vm_web.exe’s Properties dialog:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/10/image.png" target="_blank"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="vm_web.exe properties dialog" border="0" alt="vm_web.exe properties dialog" src="http://www.ningzhang.org/wp-content/uploads/2010/10/image_thumb.png" width="358" height="454" /></a></p>
<p>If the checkbox is checked and grayed out, click “Change settings for all users” button at the bottom of the dialog, and then <strong>un</strong>check “Run this program in compatibility mode” in the popped up “Compatibility for all users” dialog:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/10/image1.png" target="_blank"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: ; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="vm_web.exe compatibility for all users dialog" border="0" alt="vm_web.exe compatibility for all users dialog" src="http://www.ningzhang.org/wp-content/uploads/2010/10/image_thumb1.png" width="348" height="454" /></a></p>
<p>After that, rerun vm_web.exe and it should succeed. </p>
<p>Below is relevant section in Visual Studio readme at <a href="http://go.microsoft.com/fwlink/?LinkId=143397">http://go.microsoft.com/fwlink/?LinkId=143397</a>. I removed the registry entry for vm_web.exe and VS2010’s setup.exe, but not sure whether it helped or not. </p>
<blockquote><h6>2.1.10 Visual Studio Setup cannot be run in Program Compatibility Mode</h6>
<p>Visual Studio 2010 and/or the .NET Framework 4 Setup fails with 1603 error code or blocks running in Program Compatibility Mode.</p>
<p>Windows Program Compatibility Assistant indicates that Visual Studio Setup might not have installed correctly, and prompts the user to reinstall by using the recommended setting (program compatibility mode).</p>
<p><u>To resolve this issue:</u></p>
<p>Visual Studio Setup cannot run in program compatibility mode.&#160; Ensure that the compatibility mode setting is not enabled system-wide or for the Visual Studio Setup application.</p>
<p><b>Check the manual setting</b></p>
<p>Compatibility mode could have been set manually on the Compatibility tab on the executable file properties.</p>
<ol>
<li>On the Visual Studio Setup media, locate setup.exe. </li>
<li>Right-click setup.exe and then click Properties. </li>
<li>On the Compatibility tab, clear &quot;Run this program in compatibility mode for&quot; and then then click OK.</li>
</ol>
<p><b>Check Program Compatibility Assistant registry settings</b></p>
<p>Compatibility mode could have been set by Program Compatibility Assistant on earlier failed or canceled attempts to run Visual Studio setup.exe.</p>
<ol>
<li>Click Start, and then click Run. </li>
<li>Type <i>regedit</i>, and then click OK. </li>
<li>Browse to each of the following keys and delete any value that refers to setup.exe in the Visual Studio install path:
<ul>
<li><i>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted</i></li>
<li><i>HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers</i></li>
</ul>
</li>
</ol>
<p><b>Rerun Visual Studio Setup</b></p>
<ol>
<li>Open Windows Explorer. </li>
<li>Browse to Visual Studio setup.exe. </li>
<li>Double-click setup.exe to run Visual Studio Setup.</li>
</ol>
<p><b>Related KB Article</b></p>
<p><a href="http://support.microsoft.com/kb/931709">http://support.microsoft.com/kb/931709</a></p>
<p><b>Another Workaround:</b></p>
<p>Instead of executing the &lt;DVD ROOT&gt;\setup.exe, execute &lt;DVD ROOT&gt;\setup\setup.exe</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2010/10/03/fix-wp7-dev-tools-install-issue-setup-cannot-be-run-in-program-compatibility-mode/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Silverlight Deployment Troubleshooting Guide</title>
		<link>http://www.ningzhang.org/2010/02/17/silverlight-deployment-troubleshooting-guide/</link>
		<comments>http://www.ningzhang.org/2010/02/17/silverlight-deployment-troubleshooting-guide/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 21:41:29 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[deployment]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2010/02/17/silverlight-deployment-troubleshooting-guide/</guid>
		<description><![CDATA[After helping a few customers with Silverlight install issues, I think it may be helpful to publish a Silverlight deployment troubleshooting guide and keep it up-to-date, so here you go. Troubleshooting Steps Is Silverlight installed? on Windows, make sure “Microsoft Silverlight” is in Control Panel –&#62; Programs and Features: On Mac, make sure /Library/Internet Plug-Ins/Silverlight.plugin [...]]]></description>
			<content:encoded><![CDATA[<p>After helping a few customers with Silverlight install issues, I think it may be helpful to publish a Silverlight deployment troubleshooting guide and keep it up-to-date, so here you go. </p>
<h4>Troubleshooting Steps</h4>
<ul>
<li><strong>Is Silverlight installed?</strong>       <br />on Windows, make sure “Microsoft Silverlight” is in Control Panel –&gt; Programs and Features:       <br /><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/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="check Silverlight in appwiz.cpl" border="0" alt="check Silverlight in appwiz.cpl" src="http://www.ningzhang.org/wp-content/uploads/2010/02/image_thumb3.png" width="584" height="262" /></a>       <br />On Mac, make sure /Library/Internet Plug-Ins/Silverlight.plugin is there. If Silverlight isn’t installed, you can install the latest version from <a href="http://www.silverlight.net">http://www.silverlight.net</a> or <a href="http://www.microsoft.com/silverlight">http://www.microsoft.com/silverlight</a>.
<ul>
<li><strong>Do you have administrative privilege on the machine?</strong>           <br />You will need local administrative privilege to install Silverlight. </li>
<li><strong>Do you have </strong><a href="http://www.webshots.com/" target="_blank"><strong>webshots</strong></a><strong>/</strong><a href="http://www.kiwee.com/" target="_blank"><strong>kiwee</strong></a><strong> toolbar installed?</strong>           <br />There are known issues with Silverlight and old version of Webshots/Kiwee from <a href="http://www.americangreetings.com/" target="_blank">American Greetings</a>. The fix is to upgrade to their latest version from their web sites. Please see <a href="http://www.ningzhang.org/2010/02/17/why-do-i-keep-getting-prompted-to-install-silverlight/" target="_blank">Why do I keep getting prompted to install Silverlight?</a> for details. </li>
</ul>
</li>
<li><strong>Is Silverlight enabled?        <br /></strong>For <a href="http://www.microsoft.com/windows/internet-explorer/default.aspx" target="_blank">Internet Explorer</a>, select menu item Tools –&gt; Manage Add-ons, make sure Microsoft Silverlight is enabled for all web sites:       <br /><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/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="Make sure Silverlight is enabled with IE" border="0" alt="Make sure Silverlight is enabled with IE" src="http://www.ningzhang.org/wp-content/uploads/2010/02/image_thumb4.png" width="584" height="292" /></a> For <a href="http://www.mozilla.com/firefox" target="_blank">Firefox</a>, select menu item Tools –&gt; Add-ons, click Plugins tab, make sure Silverlight Plug-In is enabled:       <br /><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/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="Make sure Silverlight is enabled with Firefox" border="0" alt="Make sure Silverlight is enabled with Firefox" src="http://www.ningzhang.org/wp-content/uploads/2010/02/image_thumb5.png" width="519" height="347" /></a>       </li>
<li><strong>Is the issue site specific?</strong>       <br />try <a href="http://silverlight.net">http://silverlight.net</a>: if you see the showcase Silverlight application on the top right of the page, then your issue is likely to be site specific, please report the issue to the site owner. O/w, please click the <a href="http://forums.silverlight.net/" target="_blank">Forums</a> tab at <a href="http://silverlight.net">http://silverlight.net</a> page, search and/or report the issue there.&#160;&#160; </li>
<li><strong>Is the issue browser specific?</strong>       <br />try open the page in a different browser (IE/Firefox/Chrome on Windows, Safari/Firefox/Chrome on Mac) and see whether the issue repros. If it doesn’t repro, it is likely to be a browser specific configuration issue. Again, it may help to search <a href="http://forums.silverlight.net">http://forums.silverlight.net</a> to see whether this is a known issue; and if not, report it.       </li>
</ul>
<h4>Report Silverlight Setup Issue </h4>
<p>When you report a Silverlight setup issue, it’d help a lot if you can include the following information: </p>
<ul>
<li>a short description of the issue </li>
<li>operating system and browser you are using </li>
<li>the site you are having problem with </li>
<li>Silverlight setup log: under %temp% folder (like C:\Users\ningz\AppData\Local\Temp on Win7 or C:\Documents and Settings\ningz\Local Settings\Temp on WinXP), there are two files: a short Silverlight0.log and a longer SilverlightMSI.log). </li>
</ul>
<p>&#160;</p>
<h4>Other Helpful Sources</h4>
<ul>
<li>For Vancouver Olympics:
<ul>
<li><a title="http://www.mediaevangelism.com/olympics/faq2.aspx" href="http://www.mediaevangelism.com/olympics/faq2.aspx">http://www.mediaevangelism.com/olympics/faq2.aspx</a> </li>
<li><a title="http://www.mediaevangelism.com/olympics/faq.aspx" href="http://www.mediaevangelism.com/olympics/faq.aspx">http://www.mediaevangelism.com/olympics/faq.aspx</a> </li>
</ul>
</li>
<li><a href="http://blogs.msdn.com/rpomeroy/archive/2008/06/10/how-to-manually-clean-up-a-bad-silverlight-installation.aspx" target="_blank">How to manually clean up a broken Silverlight installation?</a> </li>
<li><a href="http://forums.silverlight.net/forums/p/151634/341581.aspx" target="_blank">Uninstalling Silverlight 4 Beta on OSX</a>       </li>
<li><a href="http://silverlight.net">http://silverlight.net</a> </li>
</ul>
<p>This is first version, I will keep adding content to the post and keep it up to date with issues I see reported. Thanks!</p>
<p>&#160;</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:8bcaea64-632d-49a5-b694-73a4b8f1c5c9" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Deployment" rel="tag">Deployment</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2010/02/17/silverlight-deployment-troubleshooting-guide/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Why do I keep getting prompted to install Silverlight?</title>
		<link>http://www.ningzhang.org/2010/02/17/why-do-i-keep-getting-prompted-to-install-silverlight/</link>
		<comments>http://www.ningzhang.org/2010/02/17/why-do-i-keep-getting-prompted-to-install-silverlight/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 20:06:58 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[deployment]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2010/02/17/why-do-i-keep-getting-prompted-to-install-silverlight/</guid>
		<description><![CDATA[Issue: a few people get prompted repeatedly to install Silverlight while visiting web sites like nbcolympics.com. Solution: if you have old version of Webshots Toolbar or Kiwee Toolbar from American Greetings, you should upgrade to latest version from their web sites. Details: A few people trying to view Olympics videos from www.nbcolympics.com got prompted to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Issue</strong>: a few people get prompted repeatedly to install Silverlight while visiting web sites like nbcolympics.com.</p>
<p><strong>Solution</strong>: if you have old version of <a href="http://www.webshots.com/" target="_blank">Webshots</a> Toolbar or <a href="http://www.kiwee.com/" target="_blank">Kiwee</a> Toolbar from <a href="http://www.americangreetings.com/" target="_blank">American Greetings</a>, you should upgrade to latest version from their web sites.</p>
<p><strong>Details:</strong></p>
<p>A few people trying to view Olympics videos from <a href="http://www.nbcolympics.com">www.nbcolympics.com</a> got prompted to install Silverlight, so they did and then hit F5; the page somehow prompted them to install Silverlight again, so they did again; but this time Silverlight install fails with a telltale error code <a href="http://www.microsoft.com/silverlight/resources/help.aspx?errorid=1514" target="_blank">1514</a>: Silverlight is already installed; if you want to reinstall, you need to uninstall first. So they uninstall and reinstall, but that didn’t help: they got prompted to install Silverlight again. </p>
<p>After quick investigation, I’ve found a common cause of old version of Webshots or Kiwee installed on those users’ machines. To check, you can find Webshots from Control Panel –&gt; Programs and Features:</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/image.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="start -&gt; run: appwiz.cpl, or control panel -&gt; add/remove programs" border="0" alt="start -&gt; run: appwiz.cpl, or control panel -&gt; add/remove programs" src="http://www.ningzhang.org/wp-content/uploads/2010/02/image_thumb.png" width="584" height="330" /></a> </p>
<p>or on disk: </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/image1.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="AGI files on disk" border="0" alt="AGI files on disk" src="http://www.ningzhang.org/wp-content/uploads/2010/02/image_thumb1.png" width="473" height="483" /></a> </p>
<p>The fix is to go to <a href="http://www.webshots.com">www.webshots.com</a> and upgrade to the latest version (3.1.5.7617 for now):</p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/image2.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="http://www.webshots.com/page/apps?app=anonhomepage&amp;vhost=www" border="0" alt="http://www.webshots.com/page/apps?app=anonhomepage&amp;vhost=www" src="http://www.ningzhang.org/wp-content/uploads/2010/02/image_thumb2.png" width="548" height="484" /></a> </p>
</p>
<p>then you should be able to watch Olympics video just fine with Webshots toolbar enabled as well: </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/IESLWS.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Silverlight + WebShots in IE" border="0" alt="Silverlight + WebShots in IE" src="http://www.ningzhang.org/wp-content/uploads/2010/02/IESLWS_thumb.png" width="554" height="484" /></a> </p>
<p><a href="http://www.ningzhang.org/wp-content/uploads/2010/02/FFSLWS.png" target="_blank"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Silverlight + WebShots in FF" border="0" alt="Silverlight + WebShots in FF" src="http://www.ningzhang.org/wp-content/uploads/2010/02/FFSLWS_thumb.png" width="583" height="484" /></a> </p>
<p>I will publish another blog post with common setup issues and solutions for Silverlight. </p>
</p>
<p><strong>Disclaimer</strong>:</p>
<ul>
<li>I am publishing this blog in a hurry to help those with trouble viewing Olympics video, so I may not get all facts right. I’d appreciate all feedback/correction/suggestion.</li>
<li>This is my personal blog. What I say in this blog is my opinion only. It doesn’t represent Microsoft or any other organization.</li>
</ul>
<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:9d896007-c12e-4a00-8e56-d3b0dfbc34ae" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/deployment" rel="tag">deployment</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2010/02/17/why-do-i-keep-getting-prompted-to-install-silverlight/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Silverlight Design Time Assemblies</title>
		<link>http://www.ningzhang.org/2009/11/30/silverlight-design-time-assemblies/</link>
		<comments>http://www.ningzhang.org/2009/11/30/silverlight-design-time-assemblies/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 10:07:02 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Design Time]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Blend]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/11/30/silverlight-design-time-assemblies/</guid>
		<description><![CDATA[Introduction If you write Silverlight controls, you should consider writing design time assemblies for your controls too, for two simple reasons: developer productivity: try to imagine Silverlight development without tools like Visual Studio or Blend! For custom controls, you may need to provide much of the design time experience for your controls in Visual Studio [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>If you write Silverlight controls, you should consider writing design time assemblies for your controls too, for two simple reasons:</p>
<ul>
<li>developer productivity: try to imagine Silverlight development without tools like Visual Studio or Blend! For custom controls, you may need to provide much of the design time experience for your controls in Visual Studio or Blend yourself. </li>
<li>designers: XAML and tools like Blend enable developers and designers work together. A key design criteria for Silverlight controls is to make sure designers can use them without writing a single line of code. </li>
</ul>
<p>Design time experience usually includes (but not limited to) the following:</p>
<ol>
<li>Metadata for property window, like category, infotip, custom property/binding/collection editors etc. </li>
<li>Metadata for design surface, like initializer, adorner, context menu, adapters etc. </li>
<li>Toolbox integration, like icons, control registration </li>
<li>intellisense for code editor </li>
</ol>
<p>Except intellisense (please see <a href="http://www.ningzhang.org/2009/04/22/add-rich-intellisense-for-your-silverlight-controls/" target="_blank">Add Rich Intellisense for Your Silverlight Controls</a>) and control registration (please see <a href="http://www.ningzhang.org/2009/04/30/register-silverlight-controls-with-visual-studio-and-blend/" target="_blank">Register Silverlight Controls with visual Studio and Blend</a>), above design time experience are usually delivered through design time assemblies. Below I will discuss various approaches of delivering design time experiences, in increasing complexity and flexibility, and gradually introduce pieces of the naming convention for design time assemblies. </p>
<h3>Runtime Assembly Only</h3>
<p>The simplest way to deliver design time experience is to package design time code into the runtime assemblies, especially when design time metadata are meaningful at runtime too, like <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.typeconverterattribute.aspx" target="_blank">TypeConverterAttribute</a>. </p>
<p>The pros and cons of this approach:</p>
<ul>
<li>Pro: simple
<ul>
<li>no separate design time assemblies, simpler setup </li>
<li>design time attributes are specified directly on the runtime code, easier to maintain </li>
</ul>
</li>
<li>Con: tight coupling of runtime and design time code
<ul>
<li>perf degradation because of useless design time code at runtime </li>
<li>design time dependencies (like MWDs and other VS/Blend assemblies) get dragged into runtime unnecessarily </li>
<li>can’t service runtime or design time independently </li>
<li>can’t support multiple designers (like both VS2008/Blend2 and VS2010/Blend3) </li>
</ul>
</li>
</ul>
<p>The cons are particularly bad for Silverlight, because design time assemblies are actually .NET assemblies, with references to Silverlight types. Mixing Silverlight and .NET assemblies can be challenging and confusing, and may lead to subtle bugs. Also, Silverlight applications are mostly web applications, so download size and performance are particularly important. Dragging in .NET assemblies in Silverlight applications certainly doesn’t help. So this approach is highly discouraged, unless there is strong justification for it.</p>
<h3>Shared Design Time Assembly</h3>
<p>So the revolutionary step forward is to decouple design time and runtime code, release and service them with separate assemblies. This opens up all kinds of possibilities. Of course, we need a way to link design time assemblies to their corresponding runtime assemblies, without introducing any unnecessary dependency or perf degradation to runtime assemblies. Hence the naming convention: <em><strong>if a runtime assembly Foo.dll is referenced in a Silverlight project, the designer </strong>(like Visual Studio and Blend)<strong> will first try to load design time information </strong>like icons (via another naming convention, see </em><a href="http://www.ningzhang.org/2009/01/21/how-to-add-an-toolbox-icon-for-your-silverlight-control/" target="_blank"><em>How to Add an Toolbox Icon for Your Silverlight Control</em></a><em>) and design time metadata (via interface, like </em><a href="http://msdn.microsoft.com/en-us/library/microsoft.windows.design.metadata.iregistermetadata.aspx" target="_blank"><em>IRegisterMetadata</em></a><em> for VS2008 and Blend2, or IProvideAttributeTable for VS2010 and Blend3. Please see </em><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"><em>How to Write Silverlight Design Time for All Designers: Visual Studio 2008, Blend 2; Blend 3, and Visual Studio 2010</em></a><em>) <strong>from the runtime assembly; it will then look for a design time assembly by the name Foo.Design.dll in the same directory as Foo.dll; if found, the designer will try to load design time information from Foo.Design.dll as well.</strong></em> </p>
<h3>Designer Specific Design Time Assembly</h3>
<p>Visual Studio is mostly for developers, while Blend is mostly for designers, so they have different requirements for design time experiences. Putting all design time code in one shared design time assembly introduces tight coupling among designers. So the naming convention is enhanced: <strong><em>for runtime assembly Foo.dll, there is a shared design time assembly Foo.Design.dll that’s loaded by all designers; each designer will also try to load its own design time assemblies, like Foo.VisualStudio.Design.dll for Visual Studio, and Foo.Expression.Design.dll for Blend. The designer specific design time assembly is loaded after the shared design time assembly. </em></strong>Third party designers can define their own designer specific design time assembly. <a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=19172" target="_blank">Silverlight Toolkit December 2008 Release</a> is using this naming convention. 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> and <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>Design Sub Folder</h4>
<p>So to support both Visual Studio and Blend, each runtime assembly has three design time assemblies, in the same directory, and a package (like Silverlight SDK or <a href="http://www.codeplex.com/Silverlight" target="_blank">Silverlight Toolkit</a>) usually contains several runtime assemblies. So the directory gets a bit crowded. A minor improvement is to put the design time assemblies under a Design subfolder. So the naming convention is further enhanced: <strong><em>if a designer (like Visual Studio or Blend) can’t find corresponding design time assemblies in the same directory as a runtime assembly, it will look for them in the Design subfolder, if it exists.</em></strong>&#160;</p>
<h3>Support Multiple Versions of MWDs</h3>
<p>Design time are built on top of <a href="http://msdn.microsoft.com/en-us/library/bb546938(VS.100).aspx" target="_blank">designer extensibility framework</a>, which consists of several dlls like Microsoft.Windows.Design.Extensibility.dll and Microsoft.Windows.Design.Interaction.dll. We usually call them collectively as MWDs. To make life more interesting, sometimes we have to introduce breaking changes to the extensibility framework, like VS2008 and Blend2 use MWD version 3.5, VS2010 and Blend3 use MWD version 4.0, and they are incompatible. So if you have a runtime assembly Foo.dll, and you want your users to be able to develop against it with both VS2008 and VS2010, you have to provide two sets of design time assemblies: one set built against v3.5 MWDs and used by VS2008, and another set built against v4.0 MWD and used by VS2010. The two sets of design time assemblies probably have a lot of code in common, while the one for VS2010 may have some new code to leverage the new functionalities exposed by VS2010. Since design time assemblies are loaded by name and you can’t have two files with the same name, so the naming convention is enhanced yet again:</p>
<p><strong><em>for a runtime assembly Foo.dll, the shared design time assembly is named Foo.Design*.dll, the Visual Studio specific design time assembly is named Foo.VisualStudio.Design*.dll, and the Blend specific design time assembly is named Foo.Expression.Design*.dll, where * can be zero or more valid characters for file names. When a designer (like Visual Studio or Blend) tries to load a design time assembly and several fit the naming convention, zero or one will be loaded:</em></strong></p>
<ul>
<li><strong><em>If the MWD version referenced by the design-time assembly has a different major version number than the designer’s MWD version, then the design-time assembly will not load and is bypassed. </em></strong></li>
<li><strong><em>If more than one design-time assembly is compatible with the designer’s MWD version, the Designer loads the one compiled against the highest MWD version that is less than or equal to the designer’s MWD version.</em></strong> </li>
</ul>
<p><a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30514" target="_blank">Silverlight 3 Toolkit October 2009 Release</a> uses this naming convention to support both VS2008 and Blend3/VS2010. Please see <a href="http://www.ningzhang.org/2009/10/21/silverlight-design-time-toolkit-october-2009-release-update/" target="_blank">Silverlight Design Time: Toolkit October 2009 Release Update</a>, <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>, and <a href="http://karlshifflett.wordpress.com/2009/11/20/extensibility-series-wpf-silverlight-design-time-code-sharing-part-i/" target="_blank">Extensibility Series – WPF &amp; Silverlight Design-Time Code Sharing – Part I</a> more information. </p>
<h3>Support Both WPF and Silverlight</h3>
<p>To complicate life further, since WPF and Silverlight are so awfully similar, you may be tempted to try to write it once and run with both WPF and Silverlight. You are not alone. There are many articles on how to share source code and/or binaries across Silverlight and WPF. We’d like to do that for design time assemblies too, i.e. have the same design time assemblies for both WPF and Silverlight controls. One approach is to make most of the design time assemblies platform agnostic, and limit platform specific (WPF or Silverlight) code and references to a small platform specific assembly. <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=1ea49236-0de7-41b1-81c8-a126ff39975b&amp;displaylang=en" target="_blank">Silverlight 3 SDK GDR 2</a> (installed by VS2010 automatically too) uses this approach for DataGrid designer (there is a System.Windows.Controls.Data.VisualStudio.Design.4.0.Silverlight.dll in the SDK directory). Please see <a href="http://karlshifflett.wordpress.com/2009/11/20/extensibility-series-wpf-silverlight-design-time-code-sharing-part-i/" target="_blank">Extensibility Series – WPF &amp; Silverlight Design-Time Code Sharing – Part I</a> for more information. </p>
<h3>Last One Wins</h3>
<p>The same design time metadata for a class or its member can be specified multiple times in multiple design time assemblies, which allows the shared design time assembly to specify default/common behavior and then designer specific design time assemblies to override it if necessary. The same design time metadata can also be specified multiple times within a single design time assembly (please 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> as an example, where <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx" target="_blank">DescriptionAttribute</a> for a class or its property can be added by AddDescriptions, AddAttributes and AddTables methods). So we need to know which metadata wins. The simplest and most logic design is <strong>last one wins</strong>. This is mostly true but not always. Sometimes the result can be un-deterministic when the same design time metadata is specified several times but with different values. </p>
<h3>Feedback</h3>
<p>Design time sounds easy, but devil is in the details! Feedbacks are always appreciated. Please let me know what issues you run into, what requests/improvements you’d like to make, for both design times experience and designer extensibility framework. Thanks!</p>
<p>&#160;</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:7610ba0f-16e0-4a96-8b2b-8cf4dface553" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Design+Time" rel="tag">Design Time</a>,<a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/WPF" rel="tag">WPF</a>,<a href="http://technorati.com/tags/Visual+Studio" rel="tag">Visual Studio</a>,<a href="http://technorati.com/tags/Blend" rel="tag">Blend</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/11/30/silverlight-design-time-assemblies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight Drag and Drop API</title>
		<link>http://www.ningzhang.org/2009/11/28/silverlight-drag-and-drop-api/</link>
		<comments>http://www.ningzhang.org/2009/11/28/silverlight-drag-and-drop-api/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 10:08:42 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Drag and Drop]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/11/28/silverlight-drag-and-drop-api/</guid>
		<description><![CDATA[Introduction Drag and drop is a common UX paradigm and a top requested feature. In Silverlight 4 Beta, we introduced a basic set of API to enable the most common scenario of dragging pictures files and dropping them to Silverlight applications, and we designed the API to allow us to expose more drag and drop [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Drag and drop is a common UX paradigm and a top requested feature. In Silverlight 4 Beta, we introduced a basic set of API to enable the most common scenario of dragging pictures files and dropping them to Silverlight applications, and we designed the API to allow us to expose more drag and drop functionalities down the road without API change, hopefully. </p>
<h3>API</h3>
<p>Below is the core of the new API:</p>
<p>   <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <pre id="codeSnippet" class="csharpcode"><span class="kwrd">namespace</span> System.Windows<br />{<br />    <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> UIElement : DependencyObject<br />    {<br />        <span class="rem">// Fields</span><br />        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">readonly</span> DependencyProperty AllowDropProperty;<br /><br />        <span class="rem">// Events</span><br />        <span class="kwrd">public</span> <span class="kwrd">event</span> DragEventHandler DragEnter;<br />        <span class="kwrd">public</span> <span class="kwrd">event</span> DragEventHandler DragLeave;<br />        <span class="kwrd">public</span> <span class="kwrd">event</span> DragEventHandler DragOver;<br />        <span class="kwrd">public</span> <span class="kwrd">event</span> DragEventHandler Drop;<br /><br />        <span class="rem">// Properties</span><br />        <span class="kwrd">public</span> <span class="kwrd">bool</span> AllowDrop { get; set; }<br />    }<br /><br />    <span class="kwrd">public</span> <span class="kwrd">delegate</span> <span class="kwrd">void</span> DragEventHandler(<span class="kwrd">object</span> sender, DragEventArgs e);<br /><br />    <span class="kwrd">public</span> <span class="kwrd">sealed</span> <span class="kwrd">class</span> DragEventArgs : RoutedEventArgs<br />    {<br />        <span class="rem">// Methods</span><br />        <span class="kwrd">public</span> Point GetPosition(UIElement relativeTo);<br /><br />        <span class="rem">// Properties</span><br />        <span class="kwrd">public</span> IDataObject Data { [SecuritySafeCritical] get; }<br />        <span class="kwrd">public</span> <span class="kwrd">bool</span> Handled { get; set; }<br />    }<br />}<br /><br /><span class="kwrd">namespace</span> System.Windows.Controls<br />{<br />    <span class="kwrd">public</span> <span class="kwrd">abstract</span> <span class="kwrd">class</span> Control : FrameworkElement<br />    {<br />        <span class="kwrd">protected</span> <span class="kwrd">virtual</span> <span class="kwrd">void</span> OnDragEnter(DragEventArgs e);<br />        <span class="kwrd">protected</span> <span class="kwrd">virtual</span> <span class="kwrd">void</span> OnDragLeave(DragEventArgs e);<br />        <span class="kwrd">protected</span> <span class="kwrd">virtual</span> <span class="kwrd">void</span> OnDragOver(DragEventArgs e);<br />        <span class="kwrd">protected</span> <span class="kwrd">virtual</span> <span class="kwrd">void</span> OnDrop(DragEventArgs e);<br />    }<br />}</pre>

  <br /></div>
</p>
<ul>
<li>AllowDrop: this is dependency property, indicating whether an element is a drop target. </li>
<li>DragEnter, DragLeave, DragOver &amp; Drop: these are routed events. They bubble up, and fire only on elements with AllowDrop set to true. </li>
<li>OnDragEnter, OnDragLeave, OnDragOver &amp; OnDrop: these are protected virtual functions for subclasses to override.&#160; </li>
<li>DragEventArgs: this class allows drop target event handlers or method overrides to access the data being dragged or dropped. </li>
</ul>
<h3>Usage</h3>
<p>There are primarily two ways to use Silverlight’s drag and drop API:</p>
<ul>
<li>Silverlight applications can handle those drop target events and process the files dropped in the event handlers. </li>
<li>Silverlight controls can override those drop target virtual functions to process the data being dragged and dropped, and enable themselves to be drop targets. </li>
</ul>
<h3>Limitations</h3>
<p>The drag and drop functionality shipped in Silverlight 4 Beta only enables the most common scenario: Silverlight plugin as a file drop target. Please notice the following limitations with current implementation:</p>
<ul>
<li>there is no drop source support (QueryContinueDrag &amp; GiveFeedback). </li>
<li>there is no DragDropEffects or DragDropKeyStates in DragEventArgs. </li>
<li>there is no visual for the dragged object or DragDropEffects. </li>
<li>only file drag and drop is supported:
<ul>
<li>all drop target events fire only when files are being dragged and dropped. </li>
<li>IDataObject, DataObject and DragEventArgs.Data support only one format: “FileDrop”, and the data is of type FileInfo[]. </li>
</ul>
</li>
<li>most of IDataObject methods throw NotImplementedException.<br />
    </li>
<li>for drag and drop to work on Windows, Silverlight plugin must be windowed. In another word, if &lt;param name=&quot;windowless&quot; value=&quot;true&quot;/&gt; is specified, drop events won’t fire. </li>
<li>since Silverlight plugin on Mac is always windowless, you need to hook up JavaScript drop events to trigger Silverlight drop events. In another word, if you want your Silverlight application to support file drop on Mac as well as Windows, you will need to add following script and Silverlight plugin attributes to the hosting html or aspx page: 
    <div id="codeSnippetWrapper" class="csharpcode-wrapper">
      <pre id="codeSnippet" class="csharpcode">&lt;!-- add following script before end of HEAD tag --&gt;<br />&lt;script type=<span class="str">&quot;text/javascript&quot;</span>&gt;<br />    <span class="kwrd">function</span> handleDragEnter(oEvent) {<br />        <span class="rem">// Prevent default operations</span><br />        oEvent.preventDefault();<br /><br />        <span class="kwrd">var</span> flag = silverlightControl.dragEnter(oEvent);<br /><br />        <span class="rem">// If we handled it successfully then stop propagation of the event</span><br />        <span class="kwrd">if</span> (flag)<br />            oEvent.stopPropagation();<br />    }<br /><br />    <span class="kwrd">function</span> handleDragLeave(oEvent) {<br />        <span class="rem">// Prevent default operations</span><br />        oEvent.preventDefault();<br /><br />        <span class="kwrd">var</span> flag = silverlightControl.dragLeave(oEvent);<br /><br />        <span class="rem">// If we handled it successfully then stop propagation of the event</span><br />        <span class="kwrd">if</span> (flag)<br />            oEvent.stopPropagation();<br />    }<br /><br />    <span class="kwrd">function</span> handleDragOver(oEvent) {<br />        <span class="rem">// Prevent default operations</span><br />        oEvent.preventDefault();<br /><br />        <span class="kwrd">var</span> flag = silverlightControl.dragOver(oEvent);<br /><br />        <span class="rem">// If we handled it successfully then stop propagation of the event</span><br />        <span class="kwrd">if</span> (flag)<br />            oEvent.stopPropagation();<br />    }<br /><br />    <span class="kwrd">function</span> handleDropEvent(oEvent) {<br /><br />        <span class="rem">// Prevent default operations</span><br />        oEvent.preventDefault();<br /><br />        <span class="kwrd">var</span> flag = silverlightControl.dragDrop(oEvent);<br /><br />        <span class="rem">// If we handled it successfully then stop propagation of the event</span><br />        <span class="kwrd">if</span> (flag)<br />            oEvent.stopPropagation();<br />    }<br />&lt;/script&gt;<br />&lt;!-- use JavaScript drop target events to trigger Silverlight's drop target events --&gt;<br />&lt;<span class="kwrd">object</span> data=<span class="str">&quot;data:application/x-silverlight-2,&quot;</span> type=<span class="str">&quot;application/x-silverlight-2&quot;</span> width=<span class="str">&quot;100%&quot;</span> height=<span class="str">&quot;100%&quot;</span><br />  id=<span class="str">&quot;silverlightControl&quot;</span> ondragenter=<span class="str">&quot;handleDragEnter(event)&quot;</span> ondragover=<span class="str">&quot;handleDragOver(event)&quot;</span> <br />  ondragleave=<span class="str">&quot;handleDragLeave(event)&quot;</span> ondrop=<span class="str">&quot;handleDropEvent(event)&quot;</span> &gt;<br /></pre>

      <br /></div>

<p></li>
<li>DragEventArgs.Data is only accessible in Drop event. Accessing DragEventArgs.Data in DragEnter, DragOver and DragLeave may cause <a href="http://msdn.microsoft.com/en-us/library/system.security.securityexception(VS.95).aspx" target="_blank">SecurityException</a>. And accessing Directory, DirectoryName or FullName property of the FileInfo object from DragEventArgs.Data may cause ArgumentNullException.&#160; </li>
</ul>
<ul>
<h3>Demo App</h3>
<p>Below is a demo app:</ul>
<ul>
<li>the top left nested grids use drop target event handler to display DragEventArgs info. </li>
<li>the top right nested grids contain an ImageDropTarget user control, which overrides OnDrop method to render the dropped file if it is an image. </li>
<li>the bottom listbox shows the sequence of drop target events, their bubbling up, and DragEventArgs info. </li>
</ul>
<ol></ol>
<p><a title="DragDropDemon" href="http://www.ningzhang.org/wp-content/uploads/DragDropDemo/DragDropDemo.Web/DragDropDemoTestPage.html" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Click to run DragDropDemo if you have Silverlight 4 Beta installed." border="0" alt="Click to run DragDropDemo if you have Silverlight 4 Beta installed." src="http://www.ningzhang.org/wp-content/uploads/2009/11/image1.png" width="584" height="444" /></a> </p>
<p>you can find the complete source <a href="http://www.ningzhang.org/wp-content/uploads/DragDropDemo.zip" target="_blank">here</a>. </p>
<h3>Feedback</h3>
<p>While we are excited to add drag and drop to Silverlight, we know there are a lot to finish/improve, and what we released is just a Beta. As always, your feedback is highly appreciated, and will be used as an important data point to help us prioritize the work. Thanks!</p>
<p>&#160;</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:ee3fd3e3-f006-4317-9edc-ac5b07aaf491" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Drag+and+Drop" rel="tag">Drag and Drop</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/11/28/silverlight-drag-and-drop-api/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Silverlight 4 Adds Arabic Support</title>
		<link>http://www.ningzhang.org/2009/11/18/silverlight-4-adds-arabic-support/</link>
		<comments>http://www.ningzhang.org/2009/11/18/silverlight-4-adds-arabic-support/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 20:07:00 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Arabic]]></category>
		<category><![CDATA[FlowDirection]]></category>
		<category><![CDATA[RTL]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/?p=511</guid>
		<description><![CDATA[Silverlight 4 adds support for Arabic culture: Install, configuration and runtime UI are in Arabic and RTL layout on Arabic culture Support mixed BiDi/ComplexScript text Support RTL layout with FlowDirection attribute and implemented by all controls Below screenshots demonstrate some of the support: Install UI: Configuration UI: Controls with FlowDirection set to RightToLeft: For those [...]]]></description>
			<content:encoded><![CDATA[<p>Silverlight 4 adds support for Arabic culture:</p>
<ul>
<li>Install, configuration and runtime UI are in Arabic and RTL layout on Arabic culture </li>
<li>Support mixed BiDi/ComplexScript text </li>
<li>Support RTL layout with <a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.flowdirection.aspx" target="_blank">FlowDirection</a> attribute and implemented by all controls </li>
</ul>
<p>Below screenshots demonstrate some of the support: </p>
<ul>
<li>Install UI:      <br /><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Silverlight developer runtime install UI" border="0" alt="Silverlight developer runtime install UI" src="http://www.ningzhang.org/wp-content/uploads/2009/10/sl4install2.jpg" width="513" height="240" /> </li>
<li>Configuration UI:      <br /><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Silverlight Configuration UI" border="0" alt="Silverlight Configuration UI" src="http://www.ningzhang.org/wp-content/uploads/2009/10/configabout.jpg" width="578" height="400" /> </li>
<li>Controls with FlowDirection set to RightToLeft:      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/controlsrtl2.jpg" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="RTL Layout and Controls Demo" border="0" alt="RTL Layout and Controls Demo" src="http://www.ningzhang.org/wp-content/uploads/2009/10/controlsrtl2_thumb.jpg" width="584" height="588" /></a> </li>
</ul>
<p>For those curious, you may notice that:</p>
<ul>
<li>there is a new <font face="System">ar</font> directory under <font face="system">%programfiles%\Microsoft Silverlight\4.0.41108.0</font>, besides the 10 directories that have been there since SL3: <font face="System">de, en-us, es, fr, it, ja, ko, zh-Hans, zh-Hint</font>. The <strong>ar</strong> directory contains Arabic resources for Silverlight runtime assemblies. </li>
<li>the MUI resource dlls contain Arabic resources:      <br /><a href="http://www.ningzhang.org/wp-content/uploads/2009/10/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="image" border="0" alt="image" src="http://www.ningzhang.org/wp-content/uploads/2009/10/image_thumb.png" width="584" height="348" /></a> </li>
</ul>
<p>We will continue adding more support to more cultures in Silverlight. The Arabic support debuted in Silverlight 4 Beta is particularly important, since it is the first RTL language Silverlight supports. If you notice any bug or have suggestions, please let me know. </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:131f9e58-e7cf-4dcc-ad04-001a28b64785" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Arabic" rel="tag">Arabic</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/11/18/silverlight-4-adds-arabic-support/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Silverlight Clipboard API</title>
		<link>http://www.ningzhang.org/2009/11/18/silverlight-clipboard-api/</link>
		<comments>http://www.ningzhang.org/2009/11/18/silverlight-clipboard-api/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 19:34:00 +0000</pubDate>
		<dc:creator>Ning Zhang</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Clipboard]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.ningzhang.org/2009/11/18/silverlight-clipboard-api/</guid>
		<description><![CDATA[Clipboard API in Silverlight Silverlight 4 adds Clipboard support. Check out the amazing demos by Scott Guthrie and Brian Goldfarb today at PDC that showcase scenarios enabled by Silveilght4 Clipboard support. Silverlight’s Clipboard API is a subset of WPF’s Clipboard API: It allows copy/paste Unicode strings to/from system clipboard. GetText and SetText require either of [...]]]></description>
			<content:encoded><![CDATA[<h3>Clipboard API in Silverlight</h3>
<p>Silverlight 4 adds Clipboard support. Check out the amazing demos by Scott Guthrie and Brian Goldfarb today at <a href="http://microsoftpdc.com/" target="_blank">PDC</a> that showcase scenarios enabled by Silveilght4 Clipboard support.</p>
<p>Silverlight’s Clipboard API is a subset of WPF’s <a href="http://msdn.microsoft.com/en-us/library/system.windows.clipboard.aspx" target="_blank">Clipboard</a> API:</p>
<p>   <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <pre id="codeSnippet" class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> Clipboard <br />{ <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsText(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> GetText(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetText(<span class="kwrd">string</span> text); <br />}</pre>

  <br /></div>
</p>
<p>It allows copy/paste Unicode strings to/from system clipboard. GetText and SetText require either of following to succeed: </p>
<ol>
<li>the calling Silverlight application is an elevated trust application, or </li>
<li>it is user initiated and user grants clipboard access </li>
</ol>
<p>For the second case, when GetText or SetText is first called in an user initiated event handling, Silverlight pops up a dialog like the one below (UI may change at RTW):</p>
<ul><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Clipboard Prompt" border="0" alt="Clipboard Prompt" src="http://www.ningzhang.org/wp-content/uploads/2009/11/clipboardprompt.png" width="498" height="203" /> </ul>
<ul>If user clicks yes, Silverlight will allow this and later GetText/SetText calls to succeed for this application during this session; if user clicks no, the default, Silverlight will throw a <a href="http://msdn.microsoft.com/en-us/library/system.security.securityexception(VS.95).aspx" target="_blank">SecurityException</a>. In another word, the setting is per application, per session, for both get and set access to system clipboard, and it is not persisted. </ul>
<h3>Clipboard API in JavaScript and WPF</h3>
<p>We need to consider many factors while designing Clipboard API for Silverlight. Among them, the Clipboard APIs of JavaScript and WPF are particularly interesting, because we need to study the security lessons in JavaScript and try to be compatible with WPF.</p>
<p>There is no cross browser, cross platform JavaScript API for clipboard access. IE provides <a href="http://msdn.microsoft.com/en-us/library/ms535220(VS.85).aspx" target="_blank">clipboardData</a> object that allows get/set/clear strings in system clipboard:</p>
<blockquote>
<p>bResult = window.clipboardData.setData(sDataFormat, sData);<br />
    <br />sData = window.clipboardData.getData(sDataFormat); </p>
<p>bResult = window.clipboardData.clearData([sDataFormat]);</p>
<p>where sDataFormat is a string constant of &quot;Text&quot; or &quot;URL&quot;, sData is a string, and bResult is a Boolean.</p>
</blockquote>
<p>The first time the clipboadData object is accessed, IE will prompt user to allow the script to access clipboard, and the setting is valid for the session only.</p>
<p>WPF’s Clipboard API supports more and extensible data format via <a href="http://msdn.microsoft.com/en-us/library/system.windows.idataobject.aspx" target="_blank">IDataObject</a>, and has helper functions for common formats like text, image, audio, and <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.dataformats.filedrop.aspx" target="_blank">filedrop</a>.</p>
<p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <pre id="codeSnippet" class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">class</span> Clipboard <br />{ <br />    [SecurityCritical] <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Clear(); <br /><br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsAudio(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsData(<span class="kwrd">string</span> format); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsFileDropList(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsImage(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsText(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> ContainsText(TextDataFormat format); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> Stream GetAudioStream(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">object</span> GetData(<span class="kwrd">string</span> format); <br />    [SecurityCritical] <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> IDataObject GetDataObject(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> StringCollection GetFileDropList(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> BitmapSource GetImage(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> GetText(); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> GetText(TextDataFormat format); <br /><br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">bool</span> IsCurrent(IDataObject data); <br /><br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetAudio(<span class="kwrd">byte</span>[] audioBytes); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetAudio(Stream audioStream); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetData(<span class="kwrd">string</span> format, <span class="kwrd">object</span> data); <br />    [SecurityCritical] <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetDataObject(<span class="kwrd">object</span> data); <br />    [SecurityCritical] <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetDataObject(<span class="kwrd">object</span> data, <span class="kwrd">bool</span> copy); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetFileDropList(StringCollection fileDropList); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetImage(BitmapSource image); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetText(<span class="kwrd">string</span> text); <br />    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> SetText(<span class="kwrd">string</span> text, TextDataFormat format); <br />}</pre>

  <br /></div>
</p>
<h3>Clipboard API in Windows and Mac OS X</h3>
<p>Silverlight’s clipboard API is ultimately implemented on top of the clipboard APIs of the underlying operating system. <a href="http://msdn.microsoft.com/en-us/library/ms648709(VS.85).aspx" target="_blank">Windows’ clipboard APIs</a> are documented at MSDN, below excerpt gives an overview on how to set/get clipboard data:</p>
<blockquote>
<h4>Cut and Copy Operations</h4>
<p>To place information on the clipboard, a window first clears any previous clipboard content by using the <a href="http://msdn.microsoft.com/en-us/library/ms649037(VS.85).aspx">EmptyClipboard</a> function. This function sends the <a href="http://msdn.microsoft.com/en-us/library/ms649024(VS.85).aspx">WM_DESTROYCLIPBOARD</a> message to the previous clipboard owner, frees resources associated with data on the clipboard, and assigns clipboard ownership to the window that has the clipboard open. To find out which window owns the clipboard, call the <a href="http://msdn.microsoft.com/en-us/library/ms649041(VS.85).aspx">GetClipboardOwner</a> function.</p>
<p>After emptying the clipboard, the window places data on the clipboard in as many clipboard formats as possible, ordered from the most descriptive clipboard format to the least descriptive. For each format, the window calls the <a href="http://msdn.microsoft.com/en-us/library/ms649051(VS.85).aspx">SetClipboardData</a> function, specifying the format identifier and a global memory handle. The memory handle can be NULL, indicating that the window renders the data on request. For more information, see <a href="http://msdn.microsoft.com/#_win32_Delayed_Rendering">Delayed Rendering</a>.</p>
<h4><a></a>Paste Operations</h4>
<p>To retrieve paste information from the clipboard, a window first determines the clipboard format to retrieve. Typically, a window enumerates the available clipboard formats by using the <a href="http://msdn.microsoft.com/en-us/library/ms649038(VS.85).aspx">EnumClipboardFormats</a> function and uses the first format it recognizes. This method selects the best available format according to the priority set when the data was placed on the clipboard.</p>
<p>Alternatively, a window can use the <a href="http://msdn.microsoft.com/en-us/library/ms649045(VS.85).aspx">GetPriorityClipboardFormat</a> function. This function identifies the best available clipboard format according to a specified priority. A window that recognizes only one clipboard format can simply determine whether that format is available by using the <a href="http://msdn.microsoft.com/en-us/library/ms649047(VS.85).aspx">IsClipboardFormatAvailable</a> function.</p>
<p>After determining the clipboard format to use, a window calls the <a href="http://msdn.microsoft.com/en-us/library/ms649039(VS.85).aspx">GetClipboardData</a> function. This function returns the handle to a global memory object containing data in the specified format. A window can briefly lock the memory object in order to examine or copy the data. However, a window should not free the object or leave it locked for a long period of time.</p>
</blockquote>
<p>For now, Silverlight Clipboard API only supports <a href="http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx" target="_blank">CF_UNICODETEXT</a> format for copy/paste Unicode text to/from clipboard.</p>
<p>Mac OS X uses <a href="http://developer.apple.com/mac/library/documentation/Carbon/Conceptual/Pasteboard_Prog_Guide/paste_intro/paste_intro.html" target="_blank">Pasteboard Manager</a>. It is documented at <a href="http://developer.apple.com/" target="_blank">Mac Dev Center</a>. Below excerpt (with APIs added) gives an overview:</p>
<blockquote>
<p>The copying application is responsible for placing copied or cut data onto the pasteboard:</p>
<ol>
<li>
<p>The user selects some data and invokes the Copy (or Cut) menu item.</p>
</li>
<li>
<p>If the application doesn’t already have a reference to the Clipboard pasteboard, it creates one (<a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardCreate" target="_blank">PasteboardCreate</a>).</p>
</li>
<li>
<p>The application then takes ownership of the pasteboard and clears the current contents (<a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardClear" target="_blank">PasteboardClear</a>).</p>
</li>
<li>
<p>The application assigns item IDs to the selected data.</p>
</li>
<li>
<p>If any data is to be promised, the application must register a promise keeper callback function to supply the promised data (<a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardSetPromiseKeeper" target="_blank">PasteboardSetPromiseKeeper</a>).</p>
</li>
<li>
<p>The application adds one or more flavors of each item to the pasteboard, including either the actual flavor data or a promise with each flavor (<a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardPutItemFlavor" target="_blank">PasteboardPutItemFlavor</a>).</p>
</li>
</ol>
<p>The receiving application has a slightly different set of tasks to handle the Paste action:</p>
<ol>
<li>
<p>When the application becomes active, it checks to see if the pasteboard has been modified (<a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardSynchronize" target="_blank">PasteboardSynchronize</a>). If so, it obtains a listing of the flavors on the pasteboard. If there are any flavors the application supports, it can enable its Paste menu item.</p>
</li>
<li>
<p>The user invokes the Paste menu item.</p>
</li>
<li>
<p>The application requests the item (or items) on the pasteboard in the flavors that it supports (<a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardGetItemCount" target="_blank">PasteboardGetItemCount</a>, <a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardGetItemIdentifier" target="_blank">PasteboardGetItemIdentifier</a>, <a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardCopyItemFlavors" target="_blank">PasteboardCopyItemFlavors</a>, <a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#//apple_ref/c/func/PasteboardCopyItemFlavorData" target="_blank">PasteboardCopyItemFlavorData</a>).</p>
</li>
<li>
<p>If the pasted data is to be stored as a file, the receiving application needs to set a paste location before requesting any flavor data. In any other case, the receiving application doesn’t need to worry about whether the paste data was promised or not.</p>
</li>
</ol>
<p>If the copying application’s promise keeper is called, the callback must do the following:</p>
<ul>
<li>
<p>If the data is to be stored as a file, determine the paste location specified by the receiving application.</p>
</li>
<li>
<p>Generate or otherwise prepare the promised data for transfer.</p>
</li>
<li>
<p>If the promised data is not be stored as a file, add the flavor and data to the pasteboard. Otherwise, transfer the promised data to the specified file location.</p>
</li>
</ul>
<p>Some time later, when the application quits, or when it no longer needs the pasteboard, the application can release the pasteboard reference.</p>
</blockquote>
<p>As on Windows, Silverlight Clipboard API only uses <a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Pasteboard_Reference/Reference/reference.html#jumpTo_23" target="_blank">kPasteboardClipboard</a> and <a href="http://developer.apple.com/mac/library/documentation/FileManagement/Conceptual/understanding_utis/utilist/UTIlist.html" target="_blank">kUTTypeUTF16PlainText</a> flavor to support copy/paste Unicode text to/from clipboard.</p>
<h3>Feedback</h3>
<p>We are excited to add clipboard support to Silverlight, and see all the important scenarios enabled by this simple API. I am interested in hearing your feedbacks, especially:</p>
<ul>
<li>any security concerns over Silverlight clipboard API design and implementation </li>
<li>how important it is to add support for other data type/format, and in what priority order </li>
<li>how important it is to make the API extensible, like supporting <a href="http://msdn.microsoft.com/en-us/library/system.windows.idataobject.aspx" target="_blank">IDataObject</a>, allowing custom format/flavor and delayed rendering/promised data </li>
</ul>
<ul>Thanks!</ul>
<ul></ul>
<ul>-Ning</ul>
<ul></ul>
<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:d028d2cf-c923-4643-81fb-51b31d05fbff" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Silverlight" rel="tag">Silverlight</a>,<a href="http://technorati.com/tags/Clipboard" rel="tag">Clipboard</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.ningzhang.org/2009/11/18/silverlight-clipboard-api/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

