<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Ben Lemmon's Code Ramblings</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/blemmon/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/blemmon/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:22:37 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Reading zip files from Silverlight</title>
      <link>https://docs.microsoft.com/archive/blogs/blemmon/reading-zip-files-from-silverlight</link>
      <pubDate>Wed, 25 Nov 2009 08:44:00 GMT</pubDate>
      <dc:creator><![CDATA[blemmon]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blemmon/2009/11/25/reading-zip-files-from-silverlight/</guid>
      <description><![CDATA[Silverlight doesn't have any classes from the System.IO.Compression namespace, but it's gone...]]></description>
      <content:encoded><![CDATA[<P>Silverlight doesn't have any classes from the <A href="https://msdn.microsoft.com/en-us/library/system.io.compression(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/system.io.compression(VS.85).aspx">System.IO.Compression</A> namespace, but it's gone something better, <A href="https://msdn.microsoft.com/en-us/library/cc190632(VS.95).aspx" mce_href="https://msdn.microsoft.com/en-us/library/cc190632(VS.95).aspx">Application.GetResourceStream</A>.&nbsp; It's pretty easy to take a stream to a zp file and get a stream to one of the uncomressed files inside it:</P><FONT size=2>
<P></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>StreamResourceInfo</FONT></FONT><FONT size=2> zipInfo = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>StreamResourceInfo</FONT></FONT><FONT size=2>(zipStream, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>null</FONT></FONT><FONT size=2>);<BR></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>StreamResourceInfo</FONT></FONT><FONT size=2> streamInfo = </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Application</FONT></FONT><FONT size=2>.GetResourceStream(zipInfo, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Uri</FONT></FONT><FONT size=2>(fileName, </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>UriKind</FONT></FONT><FONT size=2>.Relative));<BR></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Stream</FONT></FONT><FONT size=2> fileStream = streamInfo.Stream;</FONT></P>
<P><FONT size=2>All you need to do is provide the stream to the zip file, and the name of the file you want to extract, and in three lines of code you have a stream to the uncompressed file.&nbsp; But there's one snag: What if you don't know the name of the file(s) inside the zip file?&nbsp; There is no api to browse through the contents of the zip file.&nbsp; A common workaround is to include a manifest file in the zip which lists the contents of the zip archive, but for some, this isn't&nbsp;possible because they don't conrol the&nbsp;creation of the content,&nbsp;and are just consuming&nbsp;it.&nbsp;&nbsp;It's actually not too hard to list the files in a zip archive, with a little help&nbsp;from the <A href="https://www.pkware.com/documents/casestudies/APPNOTE.TXT" mce_href="https://www.pkware.com/documents/casestudies/APPNOTE.TXT">zip file format specification</A>&nbsp;I wrote a little utility method that lists the files contained in a zip file.&nbsp; Its usage should be straightforward.</FONT></P>
<P><FONT size=2><FONT size=2>&nbsp;</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>class</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>ZipUtil<BR></FONT></FONT><FONT size=2>{</FONT></P>
<BLOCKQUOTE>
<P><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>&lt;summary&gt;<BR></FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> Reads the file names from the header of the zip file<BR></FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>&lt;/summary&gt;<BR></FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>&lt;param name="zipStream"&gt;</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>The stream to the zip file</FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>&lt;/param&gt;<BR></FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>///</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2> </FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>&lt;returns&gt;</FONT></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>An array of file names stored within the zip file. These file names may also include relative paths.</FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>&lt;/returns&gt;<BR></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>public</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>static</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>string</FONT></FONT><FONT size=2>[] GetZipContents(System.IO.</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Stream</FONT></FONT><FONT size=2> zipStream)<BR>{</FONT></P>
<BLOCKQUOTE>
<P><FONT color=#2b91af size=2><FONT color=#2b91af size=2>List</FONT></FONT><FONT size=2>&lt;</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>string</FONT></FONT><FONT size=2>&gt; names = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>List</FONT></FONT><FONT size=2>&lt;</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>string</FONT></FONT><FONT size=2>&gt;();<BR></FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>BinaryReader</FONT></FONT><FONT size=2> reader = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>new</FONT></FONT><FONT size=2> </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>BinaryReader</FONT></FONT><FONT size=2>(zipStream);<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>while</FONT></FONT><FONT size=2> (reader.ReadUInt32() == 0x04034b50)<BR>{</FONT></P>
<BLOCKQUOTE>
<P><FONT color=#008000 size=2><FONT color=#008000 size=2>// Skip the portions of the header we don't care about<BR></FONT></FONT><FONT size=2>reader.BaseStream.Seek(14, </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>SeekOrigin</FONT></FONT><FONT size=2>.Current);<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>uint</FONT></FONT><FONT size=2> compressedSize = reader.ReadUInt32();<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>uint</FONT></FONT><FONT size=2> uncompressedSize = reader.ReadUInt32();<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> nameLength = reader.ReadUInt16();<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> extraLength = reader.ReadUInt16();<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>byte</FONT></FONT><FONT size=2>[] nameBytes = reader.ReadBytes(nameLength);<BR>names.Add(</FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>Encoding</FONT></FONT><FONT size=2>.UTF8.GetString(nameBytes, 0, nameLength));<BR>reader.BaseStream.Seek(extraLength + compressedSize, </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>SeekOrigin</FONT></FONT><FONT size=2>.Current);</FONT></P></BLOCKQUOTE>
<P><FONT size=2>}<BR></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Move the stream back to the begining<BR></FONT></FONT><FONT size=2>zipStream.Seek(0, </FONT><FONT color=#2b91af size=2><FONT color=#2b91af size=2>SeekOrigin</FONT></FONT><FONT size=2>.Begin);<BR></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> names.ToArray();</FONT></P></BLOCKQUOTE>
<P><FONT size=2>}</FONT></P></BLOCKQUOTE>
<P><FONT size=2>}</P></FONT></FONT><FONT size=2></FONT>]]></content:encoded>
    </item>
    <item>
      <title>Using the preprocessor to share incompatible XAML between SL and WPF – Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/blemmon/using-the-preprocessor-to-share-incompatible-xaml-between-sl-and-wpf-part-1</link>
      <pubDate>Wed, 29 Apr 2009 16:14:00 GMT</pubDate>
      <dc:creator><![CDATA[blemmon]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blemmon/2009/04/29/using-the-preprocessor-to-share-incompatible-xaml-between-sl-and-wpf-part-1/</guid>
      <description><![CDATA[One of the goals of Silverlight is to be a subset of WPF so that you can cross-compile the code...]]></description>
      <content:encoded><![CDATA[<P>One of the goals of Silverlight is to be a subset of WPF so that you can cross-compile the code between the two frameworks.&nbsp; This works great when you adhere to the strict subset that Silverlight provides, but when you want to deviate from that to provide richer functionality in your WPF version, you’re left with messy workarounds.&nbsp; One options is to make the changes in code using the preprocessor #if…#endif directives to conditionally include code, but what if you want to make the change in XAML?&nbsp; The XAML processor doesn’t allow preprocessor commands such as #if…#endif, so currently the only workaround is to create two copies of the XAML and change them manually.&nbsp; In doing this, you’d lose all the benefits of code sharing now that you’re maintaining two XAML files.</P>
<P>I’ve created a custom MSBuild targets file that will allow you to take full advantage of the C++ preprocessor to conditionally include code the way you’re used to doing it already.&nbsp; In part one I’ll just give a high level overview of what it does and how to use it, and I’ll provide more detail, and better incremental build functionality.</P>
<P>To use this build tool, you must add the following paths to your environment PATH variable so that the compiler knows where to find the C++ preprocessor:</P>
<P>c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\ <BR>c:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ <BR>NOTE: Your paths may be different.</P>
<P>After you’ve done that, just import PreprocessXaml.targets at the end of your csproj file (see attached example).&nbsp; This works for Silverlight projects or WPF projects.&nbsp; Once you do that, all your XAML pages will be preprocessed (except for App.xaml, we’ll add that in part 2) and compiled to Filename.i.xaml and from then on will be processed as normal.</P>
<DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; MAX-HEIGHT: 200px; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper>
<DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum1>   1:</SPAN> <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Project</SPAN> <SPAN style="COLOR: #ff0000">xmlns</SPAN><SPAN style="COLOR: #0000ff">="https://schemas.microsoft.com/developer/msbuild/2003"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum2>   2:</SPAN>   <SPAN style="COLOR: #008000">&lt;!--</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum3>   3:</SPAN> <SPAN style="COLOR: #008000">    Insert the PreprocessXaml target into the build process</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum4>   4:</SPAN> <SPAN style="COLOR: #008000">  --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum5>   5:</SPAN>   <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">PropertyGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum6>   6:</SPAN>     <SPAN style="COLOR: #008000">&lt;!-- For WPF projects --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum7>   7:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">MarkupCompilePass1DependsOn</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum8>   8:</SPAN>       $(MarkupCompilePass1DependsOn)</PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum9>   9:</SPAN>       PreprocessXaml;</PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum10>  10:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">MarkupCompilePass1DependsOn</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum11>  11:</SPAN>     <SPAN style="COLOR: #008000">&lt;!-- For Silverlight projects --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum12>  12:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">CompileXamlDependsOn</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum13>  13:</SPAN>       $(CompileXamlDependsOn)</PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum14>  14:</SPAN>       PreprocessXaml;</PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum15>  15:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">CompileXamlDependsOn</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum16>  16:</SPAN>   <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">PropertyGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum17>  17:</SPAN>   <SPAN style="COLOR: #008000">&lt;!--</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum18>  18:</SPAN> <SPAN style="COLOR: #008000">    Runs the C++ preprocessor over all XAML files before they are compiled and packaged.</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum19>  19:</SPAN> <SPAN style="COLOR: #008000">    This allows for conditional inclusion of XAML such as </SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum20>  20:</SPAN> <SPAN style="COLOR: #008000">    &lt;TextBlock</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum21>  21:</SPAN> <SPAN style="COLOR: #008000">    #if SILVERLIGHT</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum22>  22:</SPAN> <SPAN style="COLOR: #008000">      Text="This is in Silverlight"</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum23>  23:</SPAN> <SPAN style="COLOR: #008000">    #else</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum24>  24:</SPAN> <SPAN style="COLOR: #008000">      Text="This is in WPF"</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum25>  25:</SPAN> <SPAN style="COLOR: #008000">    #endif</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum26>  26:</SPAN> <SPAN style="COLOR: #008000">    /&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum27>  27:</SPAN> <SPAN style="COLOR: #008000">    or use #define to define constants etc.</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum28>  28:</SPAN> <SPAN style="COLOR: #008000">  --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum29>  29:</SPAN>   <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Target</SPAN> <SPAN style="COLOR: #ff0000">Name</SPAN><SPAN style="COLOR: #0000ff">="PreprocessXaml"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum30>  30:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ItemGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum31>  31:</SPAN>       <SPAN style="COLOR: #008000">&lt;!-- Create a list of pages post-preprocess --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum32>  32:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">PreprocessedPages</SPAN> <SPAN style="COLOR: #ff0000">Include</SPAN>="@(<SPAN style="COLOR: #ff0000">Page-</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN>'%(RelativeDir)%(Filename).i%(Extension)')" <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum33>  33:</SPAN>       <SPAN style="COLOR: #008000">&lt;!-- We don't want to include the unprocessed files as resources, include the preprocessed files instead --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum34>  34:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Resource</SPAN> <SPAN style="COLOR: #ff0000">Remove</SPAN><SPAN style="COLOR: #0000ff">="@(Page)"</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum35>  35:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Resource</SPAN> <SPAN style="COLOR: #ff0000">Include</SPAN><SPAN style="COLOR: #0000ff">="@(PreprocessedPages)"</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum36>  36:</SPAN>       <SPAN style="COLOR: #008000">&lt;!-- Convert the DefineConstants property into an ItemGroup --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum37>  37:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">XamlConstants</SPAN> <SPAN style="COLOR: #ff0000">Include</SPAN><SPAN style="COLOR: #0000ff">="$(DefineConstants)"</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum38>  38:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ItemGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum39>  39:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">PropertyGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum40>  40:</SPAN>       <SPAN style="COLOR: #008000">&lt;!-- Convert the XamlConstants ItemGroup into a list command line switches for CL.exe --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum41>  41:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">CommandLineDefineConstants</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN>@(XamlConstants-<SPAN style="COLOR: #0000ff">&gt;</SPAN>'/D%(Identity)',' ')<SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">CommandLineDefineConstants</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum42>  42:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">PropertyGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum43>  43:</SPAN>     <SPAN style="COLOR: #008000">&lt;!-- Run the preprocessor --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum44>  44:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Exec</SPAN> <SPAN style="COLOR: #ff0000">Command</SPAN><SPAN style="COLOR: #0000ff">="CL.exe /nologo /EP $(CommandLineDefineConstants) &amp;quot;%(Page.FullPath)&amp;quot; &amp;gt; %(RelativeDir)%(Filename).i%(Extension)"</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum45>  45:</SPAN>     <SPAN style="COLOR: #008000">&lt;!-- Replace the pages with the preprocessed pages so that subsequent targets will use the preprocessed files --&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum46>  46:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ItemGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum47>  47:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Page</SPAN> <SPAN style="COLOR: #ff0000">Remove</SPAN><SPAN style="COLOR: #0000ff">="**"</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum48>  48:</SPAN>       <SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">Page</SPAN> <SPAN style="COLOR: #ff0000">Include</SPAN><SPAN style="COLOR: #0000ff">="@(PreprocessedPages)"</SPAN> <SPAN style="COLOR: #0000ff">/&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum49>  49:</SPAN>     <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ItemGroup</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum50>  50:</SPAN>   <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">Target</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--><PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"><SPAN style="COLOR: #606060" id=lnum51>  51:</SPAN> <SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">Project</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></PRE><!--CRLF--></DIV></DIV>
<P align=center>PreprocessXaml.targets</P>
<P align=left>Attached is a simple project that shows conditional compilation of XAML at work.</P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/57/64/19/PreprocessorTest.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-57-64-19/PreprocessorTest.zip">PreprocessorTest.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Piping Converters in WPF and Silverlight</title>
      <link>https://docs.microsoft.com/archive/blogs/blemmon/piping-converters-in-wpf-and-silverlight</link>
      <pubDate>Sun, 22 Mar 2009 01:30:00 GMT</pubDate>
      <dc:creator><![CDATA[blemmon]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blemmon/2009/03/22/piping-converters-in-wpf-and-silverlight/</guid>
      <description><![CDATA[One limitation in WPF and Silverlight is that a Binding can only have one converter.&nbsp; At least...]]></description>
      <content:encoded><![CDATA[<P>One limitation in WPF and Silverlight is that a Binding can only have one converter.&nbsp; At least for me, this has meant that I've created a lot of very specific converters in my projects.&nbsp; If I needed a converter to format a string then turn it into a uri, I'd make a class to do just that.&nbsp; After getting frustrated by the abundance of single use converters, I decided there has to be another way.&nbsp; I tried thinking up this clever scheme where I'd use ConverterParameter as a small-scripting&nbsp;language to tell it which steps to perform.&nbsp; Anyone reading this is probably already thinking, "that's not clever, that's a crappy idea," and they're right.&nbsp; It is a crappy idea, which is why I didn't do it.&nbsp; You see, you have to think up a few bad ideas first so that you know your good idea is actually good.</P>
<P>I'm sure I'm not the only programmer who goes to bed with a problem in his head, and dreams the solution: Well, that's exactly how this came about.&nbsp; So I wrote up this simple converter that has a list of child converters and pipes the&nbsp;output of each to the input of the next.&nbsp;&nbsp;Each converter must have a CanConvertAttribute describing the types it can convert from and to so that the PipingConverter can pass the&nbsp;correct targetType to the next converter in line.&nbsp; I've allowed for multiple CanConvertAttributes&nbsp;in case&nbsp;one converter&nbsp;can serve many purposes.&nbsp; The PipingConverter performs a&nbsp;depth first search to find the first valid conversion path between the&nbsp;value and the final target type.&nbsp;I've attached the Silverlight project which can easily be ported to WPF to get the same effect.&nbsp; I'll also leave it as an exercise for the reader to implement two way conversion.</P>
<P>To make use of this, simply create your PipingConverter in xaml or code, and add the child converters in the order you want them executed.&nbsp; So if you wanted to take a list of strings from one of your data objects, sort it, convert it to a comma delimited string, then make it all caps, your code would look like:<FONT color=#a31515 size=2><FONT color=#a31515 size=2></P>
<P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&lt;</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>local</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>:</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>PipingConverter</FONT></FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2> x</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>:</FONT></FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2>Key</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>="ListConverter"&gt;<BR></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&nbsp;&nbsp;&nbsp;&nbsp; &lt;</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>local</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>:</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>SortListConverter</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2> /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; </FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&lt;</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>local</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>:</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>ListToStringConverter</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2> /&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; </FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&lt;</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>local</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>:</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>StringCaseConverter</FONT></FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2> LetterCase</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>="Upper" /&gt;<BR></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&lt;/</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>local</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>:</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>PipingConverter</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>&gt;</P></FONT></FONT>
<P mce_keep="true">and to bind, simply use:</P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>&lt;</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>TextBlock</FONT></FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2> Text</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>="{</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>Binding</FONT></FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2> Converter</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>={</FONT></FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>StaticResource</FONT></FONT><FONT color=#ff0000 size=2><FONT color=#ff0000 size=2> ListConverter</FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>}}" /&gt;</FONT></FONT></P>
<P>It fits so well that I'm surprised that it wasn't included at least in WPF.&nbsp; Maybe someday, I'll try doing the same thing for multi converters.</P>
<P mce_keep="true">&nbsp;</P>
<P>NOTE: After writing this, I found that Josh Smith has posted a quite simmilar solution <A href="https://www.codeproject.com/KB/WPF/PipingValueConverters_WPF.aspx" target=_blank mce_href="https://www.codeproject.com/KB/WPF/PipingValueConverters_WPF.aspx">here</A>.&nbsp; I didn't know of his solution before coming up with mine, so that fact that they turned out so similarly just validates both of our approaches.</P>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/09/49/75/69/PipingConverter.zip" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-49-75-69/PipingConverter.zip">PipingConverter.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Animating margins in Silverlight</title>
      <link>https://docs.microsoft.com/archive/blogs/blemmon/animating-margins-in-silverlight</link>
      <pubDate>Tue, 17 Mar 2009 22:25:00 GMT</pubDate>
      <dc:creator><![CDATA[blemmon]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blemmon/2009/03/17/animating-margins-in-silverlight/</guid>
      <description><![CDATA[So I ran into a problem the other day where I needed to animate&nbsp;a margin of a control, but...]]></description>
      <content:encoded><![CDATA[<P>So I ran into a problem the other day where I needed to animate&nbsp;a margin of a control, but Silverlight doesn't&nbsp;allow for&nbsp;animating Thickness objects (<A class="" href="https://msdn.microsoft.com/en-us/library/system.windows.media.animation.thicknessanimation.aspx" target=_blank mce_href="https://msdn.microsoft.com/en-us/library/system.windows.media.animation.thicknessanimation.aspx">WPF does</A>).&nbsp; The solution I came up with is very simple and can be used to animate the Margin, Padding, or BorderThickness of any control.&nbsp; Since Silverlight doesn't support custom animations, we'll have to work with this hack for now.</P><!-- code formatted by https://manoli.net/csharpformat/ -->
<STYLE type=text/css>
.csharpcode
{
         overflow: scroll;
         width: 450px;
         height: 700px;
}
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: Consolas, "Courier New", Courier, Monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}

.csharpcode pre { margin: 0em; }

.csharpcode .rem { color: #008000; }

.csharpcode .kwrd { color: #0000ff; }

.csharpcode .str { color: #006080; }

.csharpcode .op { color: #0000c0; }

.csharpcode .preproc { color: #cc6633; }

.csharpcode .asp { background-color: #ffff00; }

.csharpcode .html { color: #800000; }

.csharpcode .attr { color: #ff0000; }

.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}

.csharpcode .lnum { color: #606060; }
</STYLE>

<DIV class=csharpcode><PRE class=alt><SPAN class=lnum>   1:  </SPAN><SPAN class=kwrd>using</SPAN> System;</PRE><PRE><SPAN class=lnum>   2:  </SPAN><SPAN class=kwrd>using</SPAN> System.Net;</PRE><PRE class=alt><SPAN class=lnum>   3:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows;</PRE><PRE><SPAN class=lnum>   4:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Controls;</PRE><PRE class=alt><SPAN class=lnum>   5:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Documents;</PRE><PRE><SPAN class=lnum>   6:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Ink;</PRE><PRE class=alt><SPAN class=lnum>   7:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Input;</PRE><PRE><SPAN class=lnum>   8:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Media;</PRE><PRE class=alt><SPAN class=lnum>   9:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Media.Animation;</PRE><PRE><SPAN class=lnum>  10:  </SPAN><SPAN class=kwrd>using</SPAN> System.Windows.Shapes;</PRE><PRE class=alt><SPAN class=lnum>  11:  </SPAN>&nbsp;</PRE><PRE><SPAN class=lnum>  12:  </SPAN><SPAN class=kwrd>namespace</SPAN> SLApp1</PRE><PRE class=alt><SPAN class=lnum>  13:  </SPAN>{</PRE><PRE><SPAN class=lnum>  14:  </SPAN>    <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>class</SPAN> ThicknessAnimation</PRE><PRE class=alt><SPAN class=lnum>  15:  </SPAN>    {</PRE><PRE><SPAN class=lnum>  16:  </SPAN>        <SPAN class=rem>// The time along the animation from 0-1</SPAN></PRE><PRE class=alt><SPAN class=lnum>  17:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> DependencyProperty TimeProperty = DependencyProperty.RegisterAttached(<SPAN class=str>"Time"</SPAN>, <SPAN class=kwrd>typeof</SPAN>(<SPAN class=kwrd>double</SPAN>), <SPAN class=kwrd>typeof</SPAN>(DoubleAnimation), <SPAN class=kwrd>new</SPAN> PropertyMetadata(OnTimeChanged));</PRE><PRE><SPAN class=lnum>  18:  </SPAN>        <SPAN class=rem>// The object being animated</SPAN></PRE><PRE class=alt><SPAN class=lnum>  19:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> DependencyProperty TargetProperty = DependencyProperty.RegisterAttached(<SPAN class=str>"Target"</SPAN>, <SPAN class=kwrd>typeof</SPAN>(DependencyObject), <SPAN class=kwrd>typeof</SPAN>(ThicknessAnimation), <SPAN class=kwrd>null</SPAN>);</PRE><PRE><SPAN class=lnum>  20:  </SPAN>        <SPAN class=rem>// The thickness we're animating to</SPAN></PRE><PRE class=alt><SPAN class=lnum>  21:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> DependencyProperty FromProperty = DependencyProperty.RegisterAttached(<SPAN class=str>"From"</SPAN>, <SPAN class=kwrd>typeof</SPAN>(Thickness), <SPAN class=kwrd>typeof</SPAN>(DependencyObject), <SPAN class=kwrd>null</SPAN>);</PRE><PRE><SPAN class=lnum>  22:  </SPAN>        <SPAN class=rem>// The tickness we're animating from</SPAN></PRE><PRE class=alt><SPAN class=lnum>  23:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> DependencyProperty ToProperty = DependencyProperty.RegisterAttached(<SPAN class=str>"To"</SPAN>, <SPAN class=kwrd>typeof</SPAN>(Thickness), <SPAN class=kwrd>typeof</SPAN>(DependencyObject), <SPAN class=kwrd>null</SPAN>);</PRE><PRE><SPAN class=lnum>  24:  </SPAN>        <SPAN class=rem>// The target property to animate to.  Should have a property type of Thickness</SPAN></PRE><PRE class=alt><SPAN class=lnum>  25:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> DependencyProperty TargetPropertyProperty = DependencyProperty.RegisterAttached(<SPAN class=str>"TargetProperty"</SPAN>, <SPAN class=kwrd>typeof</SPAN>(DependencyProperty), <SPAN class=kwrd>typeof</SPAN>(DependencyObject), <SPAN class=kwrd>null</SPAN>);</PRE><PRE><SPAN class=lnum>  26:  </SPAN>&nbsp;</PRE><PRE class=alt><SPAN class=lnum>  27:  </SPAN>        <SPAN class=rem>/// &lt;summary&gt;</SPAN></PRE><PRE><SPAN class=lnum>  28:  </SPAN>        <SPAN class=rem>/// Creates a Timeline used to animate the thickness of an object</SPAN></PRE><PRE class=alt><SPAN class=lnum>  29:  </SPAN>        <SPAN class=rem>/// &lt;/summary&gt;</SPAN></PRE><PRE><SPAN class=lnum>  30:  </SPAN>        <SPAN class=rem>/// &lt;param name="target"&gt;The object to animate&lt;/param&gt;</SPAN></PRE><PRE class=alt><SPAN class=lnum>  31:  </SPAN>        <SPAN class=rem>/// &lt;param name="targetProperty"&gt;The property on the object to animate&lt;/param&gt;</SPAN></PRE><PRE><SPAN class=lnum>  32:  </SPAN>        <SPAN class=rem>/// &lt;param name="duration"&gt;The length of the animation&lt;/param&gt;</SPAN></PRE><PRE class=alt><SPAN class=lnum>  33:  </SPAN>        <SPAN class=rem>/// &lt;param name="from"&gt;The begining thickness&lt;/param&gt;</SPAN></PRE><PRE><SPAN class=lnum>  34:  </SPAN>        <SPAN class=rem>/// &lt;param name="to"&gt;The final thickness&lt;/param&gt;</SPAN></PRE><PRE class=alt><SPAN class=lnum>  35:  </SPAN>        <SPAN class=rem>/// &lt;returns&gt;A timeline object that can be added to a storyboard&lt;/returns&gt;</SPAN></PRE><PRE><SPAN class=lnum>  36:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> Timeline Create(DependencyObject target, DependencyProperty targetProperty, Duration duration, Thickness from, Thickness to)</PRE><PRE class=alt><SPAN class=lnum>  37:  </SPAN>        {</PRE><PRE><SPAN class=lnum>  38:  </SPAN>            DoubleAnimation timeAnimation = <SPAN class=kwrd>new</SPAN> DoubleAnimation() {    From = 0, To = 1, Duration = duration };</PRE><PRE class=alt><SPAN class=lnum>  39:  </SPAN>            timeAnimation.SetValue(TargetProperty, target);</PRE><PRE><SPAN class=lnum>  40:  </SPAN>            timeAnimation.SetValue(TargetPropertyProperty, targetProperty);</PRE><PRE class=alt><SPAN class=lnum>  41:  </SPAN>            timeAnimation.SetValue(FromProperty, from);</PRE><PRE><SPAN class=lnum>  42:  </SPAN>            timeAnimation.SetValue(ToProperty, to);</PRE><PRE class=alt><SPAN class=lnum>  43:  </SPAN>            Storyboard.SetTargetProperty(timeAnimation, <SPAN class=kwrd>new</SPAN> PropertyPath(<SPAN class=str>"(ThicknessAnimation.Time)"</SPAN>));</PRE><PRE><SPAN class=lnum>  44:  </SPAN>            Storyboard.SetTarget(timeAnimation, timeAnimation);</PRE><PRE class=alt><SPAN class=lnum>  45:  </SPAN>            <SPAN class=kwrd>return</SPAN> timeAnimation;</PRE><PRE><SPAN class=lnum>  46:  </SPAN>        }</PRE><PRE class=alt><SPAN class=lnum>  47:  </SPAN>&nbsp;</PRE><PRE><SPAN class=lnum>  48:  </SPAN>        <SPAN class=rem>/// &lt;summary&gt;</SPAN></PRE><PRE class=alt><SPAN class=lnum>  49:  </SPAN>        <SPAN class=rem>/// Silverlight's animation system is animating time from 0 to 1.  When time changes we update the thickness to be time</SPAN></PRE><PRE><SPAN class=lnum>  50:  </SPAN>        <SPAN class=rem>/// percent between from and to</SPAN></PRE><PRE class=alt><SPAN class=lnum>  51:  </SPAN>        <SPAN class=rem>/// &lt;/summary&gt;</SPAN></PRE><PRE><SPAN class=lnum>  52:  </SPAN>        <SPAN class=kwrd>private</SPAN> <SPAN class=kwrd>static</SPAN> <SPAN class=kwrd>void</SPAN> OnTimeChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)</PRE><PRE class=alt><SPAN class=lnum>  53:  </SPAN>        {</PRE><PRE><SPAN class=lnum>  54:  </SPAN>            DoubleAnimation animation = (DoubleAnimation)sender;</PRE><PRE class=alt><SPAN class=lnum>  55:  </SPAN>            <SPAN class=kwrd>double</SPAN> time = GetTime(animation);</PRE><PRE><SPAN class=lnum>  56:  </SPAN>            Thickness from = (Thickness)sender.GetValue(FromProperty);</PRE><PRE class=alt><SPAN class=lnum>  57:  </SPAN>            Thickness to = (Thickness)sender.GetValue(ToProperty);</PRE><PRE><SPAN class=lnum>  58:  </SPAN>            DependencyProperty targetProperty = (DependencyProperty)sender.GetValue(TargetPropertyProperty);</PRE><PRE class=alt><SPAN class=lnum>  59:  </SPAN>            DependencyObject target = (DependencyObject)sender.GetValue(TargetProperty);</PRE><PRE><SPAN class=lnum>  60:  </SPAN>            target.SetValue(targetProperty, <SPAN class=kwrd>new</SPAN> Thickness((to.Left - from.Left) * time + from.Left,</PRE><PRE class=alt><SPAN class=lnum>  61:  </SPAN>                                                          (to.Top - from.Top) * time + from.Top,</PRE><PRE><SPAN class=lnum>  62:  </SPAN>                                                          (to.Right - from.Right) * time + from.Right,</PRE><PRE class=alt><SPAN class=lnum>  63:  </SPAN>                                                          (to.Bottom - from.Bottom) * time + from.Bottom));</PRE><PRE><SPAN class=lnum>  64:  </SPAN>            </PRE><PRE class=alt><SPAN class=lnum>  65:  </SPAN>        }</PRE><PRE><SPAN class=lnum>  66:  </SPAN>&nbsp;</PRE><PRE class=alt><SPAN class=lnum>  67:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> <SPAN class=kwrd>double</SPAN> GetTime(DoubleAnimation animation)</PRE><PRE><SPAN class=lnum>  68:  </SPAN>        {</PRE><PRE class=alt><SPAN class=lnum>  69:  </SPAN>            <SPAN class=kwrd>return</SPAN> (<SPAN class=kwrd>double</SPAN>)animation.GetValue(TimeProperty);</PRE><PRE><SPAN class=lnum>  70:  </SPAN>        }</PRE><PRE class=alt><SPAN class=lnum>  71:  </SPAN>&nbsp;</PRE><PRE><SPAN class=lnum>  72:  </SPAN>        <SPAN class=kwrd>public</SPAN> <SPAN class=kwrd>static</SPAN> <SPAN class=kwrd>void</SPAN> SetTime(DoubleAnimation animation, <SPAN class=kwrd>double</SPAN> <SPAN class=kwrd>value</SPAN>)</PRE><PRE class=alt><SPAN class=lnum>  73:  </SPAN>        {</PRE><PRE><SPAN class=lnum>  74:  </SPAN>            animation.SetValue(TimeProperty, <SPAN class=kwrd>value</SPAN>);</PRE><PRE class=alt><SPAN class=lnum>  75:  </SPAN>        }</PRE><PRE><SPAN class=lnum>  76:  </SPAN>    }</PRE><PRE class=alt><SPAN class=lnum>  77:  </SPAN>}</PRE></DIV>
<P mce_keep="true">To use this, simply call ThicknessAnimation.Create with the necessary parameters, add the timeline to a storyboard, and call storyboard.Begin()</P>]]></content:encoded>
    </item>
    <item>
      <title>Introduction</title>
      <link>https://docs.microsoft.com/archive/blogs/blemmon/introduction</link>
      <pubDate>Tue, 17 Mar 2009 20:21:00 GMT</pubDate>
      <dc:creator><![CDATA[blemmon]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/blemmon/2009/03/17/introduction/</guid>
      <description><![CDATA[Before we get off to the fun stuff (a.k.a. programming), I think it's best for me to introduce...]]></description>
      <content:encoded><![CDATA[Before we get off to the fun stuff (a.k.a. programming), I think it's best for me to introduce myself.&nbsp; I'm a developer at Microsoft working for MSN.&nbsp; I began programming around age 14, working in QBasic 4.5, and have been addicted ever since.&nbsp; My language of choice is C#, and I love to play with Silverlight, WPF, WCF, ASP.NET, SQL, HTML, Javascript, and whatever else it takes to get the job done.&nbsp;&nbsp;I decided to start this blog to share some of my projects and ideas, but just because I'm the guy with the blog, that doesn't mean I'm right so make sure and comment and we'll both learn.]]></content:encoded>
    </item>
  </channel>
</rss>