<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Stefan Wick's Weblog - Development with Silverlight, WPF and Tablet PC : VisualBrush</title><link>http://blogs.msdn.com/swick/archive/tags/VisualBrush/default.aspx</link><description>Tags: VisualBrush</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Ink Reflections - in Silverlight</title><link>http://blogs.msdn.com/swick/archive/2007/12/02/ink-reflections-now-in-silverlight.aspx</link><pubDate>Sun, 02 Dec 2007 08:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6639763</guid><dc:creator>swick</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/swick/comments/6639763.aspx</comments><wfw:commentRss>http://blogs.msdn.com/swick/commentrss.aspx?PostID=6639763</wfw:commentRss><description>&lt;P&gt;I have received several question from folks about&amp;nbsp;my earlier post&amp;nbsp;on &lt;A class="" href="http://blogs.msdn.com/swick/archive/2007/10/31/fun-with-ink-xaml-part1-ink-reflections.aspx" mce_href="http://blogs.msdn.com/swick/archive/2007/10/31/fun-with-ink-xaml-part1-ink-reflections.aspx"&gt;Ink Reflections in WPF&lt;/A&gt;. People were curious how to accomplish the same or a similar effect in Silverlight, in the absence of the VisualBrush object.&lt;/P&gt;
&lt;P&gt;Clearly, WPF's VisualBrush is the main object that enables scenarios like this and it definitely makes their implementation&amp;nbsp;straightforward. However, in Silverlight you can also accomplish effects like this with little bit of extra coding.&lt;/P&gt;
&lt;P&gt;First of all, Silverlight has an ImageBrush and a VideoBrush, so as long as the visul you want to mirror is an image or a video, you can apply the same technique as used in my WPF sample and you are done.&lt;/P&gt;
&lt;P&gt;If you want to mirror&amp;nbsp;a different&amp;nbsp;type of visual, you will have to manage the mirror yourself, meaning you have to create a secondary, mirrored visual and update it whenever the original changes.&lt;/P&gt;
&lt;P&gt;I have created a sample that demonstrates both techniques together. The yellow background with silver border is an image that gets mirrored using an ImageBrush. The ink you draw (and erase) gets mirrored programmatically using some JavaScript code-behind.&lt;/P&gt;
&lt;P&gt;The sample's source code is attached.&amp;nbsp;A live version, hosted via Silverlight Streaming, is included below for you try out.&lt;/P&gt;&lt;IFRAME src="http://silverlight.services.live.com/invoke/34348/InkReflections/iframe.html" frameBorder=0 width=545 scrolling=no height=360 mce_src="http://silverlight.services.live.com/invoke/34348/InkReflections/iframe.html"&gt;&lt;/IFRAME&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6639763" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/swick/attachment/6639763.ashx" length="10206" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/swick/archive/tags/Ink/default.aspx">Ink</category><category domain="http://blogs.msdn.com/swick/archive/tags/VisualBrush/default.aspx">VisualBrush</category><category domain="http://blogs.msdn.com/swick/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.msdn.com/swick/archive/tags/Silverlight+Ink/default.aspx">Silverlight Ink</category><category domain="http://blogs.msdn.com/swick/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/swick/archive/tags/Silverlight+Samples/default.aspx">Silverlight Samples</category></item><item><title>Fun with Ink &amp; Xaml - Part1: Ink Reflections</title><link>http://blogs.msdn.com/swick/archive/2007/10/31/fun-with-ink-xaml-part1-ink-reflections.aspx</link><pubDate>Thu, 01 Nov 2007 00:44:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5805718</guid><dc:creator>swick</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/swick/comments/5805718.aspx</comments><wfw:commentRss>http://blogs.msdn.com/swick/commentrss.aspx?PostID=5805718</wfw:commentRss><description>&lt;P mce_keep="true"&gt;With the InkCanvas element in WPF you can create stunning inking experiences for TabletPC users (mouse users can play along, too!). Several very cool scenarios can be enabled just by writing markup - without any additional code behind.&lt;/P&gt;
&lt;P mce_keep="true"&gt;Here is a first example: an ink input field (takes input from either stylus or mouse) that has a dynamic reflection effect. While the user is inking, the reflection gets updated dynamically, in real-time. Implemented entirely in markup.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IMG title="Ink Reflections - using XAML" style="WIDTH: 503px; HEIGHT: 306px" height=306 alt="Ink Reflections - using XAML" src="http://blogs.msdn.com/photos/swick/images/5805750/original.aspx" width=503 mce_src="http://blogs.msdn.com/photos/swick/images/5805750/original.aspx"&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The key feature (besides InkCanvas) here is the &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms749021.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms749021.aspx"&gt;VisualBrush&lt;/A&gt;. The bottom part of the scene is a Rectangle that gets painted with a VisualBrush that is bound to the ink input control. As a result it gets updated dynamically as the user draws onto the control.&amp;nbsp;Below is the relevant piece of markup. The full XAML file is &lt;A class="" href="http://blogs.msdn.com/swick/attachment/5805718.ashx" mce_href="http://blogs.msdn.com/swick/attachment/5805718.ashx"&gt;attached to this post&lt;/A&gt;. You can load it into XamlPad to play with it, or just open in IE and ink away.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp; &amp;lt;Rectangle.Fill&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;VisualBrush &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Visual="{Binding ElementName=inkBorder}"&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;VisualBrush.RelativeTransform&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TransformGroup&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ScaleTransform ScaleX="1" ScaleY="-1" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TranslateTransform Y="1" /&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/TransformGroup&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/VisualBrush.RelativeTransform&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/VisualBrush&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/Rectangle.Fill&amp;gt;&lt;BR&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;More information about creating reflections using VisualBrush can be found in this &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/aa970263.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/aa970263.aspx"&gt;MSDN How-To Topic&lt;/A&gt;. Additional &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms752330.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms752330.aspx"&gt;How-To topics on Ink in WPF&lt;/A&gt; are also available on MSDN.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;Next post in this series:&lt;/STRONG&gt; &lt;A class="" href="http://blogs.msdn.com/swick/archive/2007/11/02/fun-with-ink-xaml-part2-zoom-and-scroll.aspx" mce_href="http://blogs.msdn.com/swick/archive/2007/11/02/fun-with-ink-xaml-part2-zoom-and-scroll.aspx"&gt;Fun with Ink &amp;amp; Xaml - Part2: Zoom and Scroll&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5805718" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/swick/attachment/5805718.ashx" length="2213" type="application/xaml+xml" /><category domain="http://blogs.msdn.com/swick/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/swick/archive/tags/Tablet/default.aspx">Tablet</category><category domain="http://blogs.msdn.com/swick/archive/tags/WPF+Samples/default.aspx">WPF Samples</category><category domain="http://blogs.msdn.com/swick/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/swick/archive/tags/InkCanvas/default.aspx">InkCanvas</category><category domain="http://blogs.msdn.com/swick/archive/tags/Ink/default.aspx">Ink</category><category domain="http://blogs.msdn.com/swick/archive/tags/VisualBrush/default.aspx">VisualBrush</category><category domain="http://blogs.msdn.com/swick/archive/tags/XAML/default.aspx">XAML</category><category domain="http://blogs.msdn.com/swick/archive/tags/Fun+with+Ink+_2600_amp_3B00_+Xaml/default.aspx">Fun with Ink &amp;amp; Xaml</category></item></channel></rss>