<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Program With .NET</title>
    <link>http://programwith.net/</link>
    <description>Matt Casto's .NET Journal</description>
    <language>en-us</language>
    <copyright>Matt Casto</copyright>
    <lastBuildDate>Tue, 22 Apr 2008 02:55:36 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.0.7226.0</generator>
    <managingEditor>mattcasto@gmail.com</managingEditor>
    <webMaster>mattcasto@gmail.com</webMaster>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=c41366fc-ccb3-4d12-8431-b355e6c4b39f</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=c41366fc-ccb3-4d12-8431-b355e6c4b39f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is a very simple animation that can be used just about anywhere.
</p>
        <p>
          <iframe style="width: 300px; height: 150px" src="http://silverlight.services.live.com/invoke/63993/Crawling%20Border/iframe.html" frameborder="0" scrolling="no">
          </iframe>
        </p>
        <p>
[[ If you're viewing this post through an RSS reader, you won't be able to see the
Silverlight example ]]
</p>
        <p>
Following is my Page.xaml for this example.  There was no code needed.
</p>
        <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4">
          <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">UserControl</span>
              <span style="color: #ff0000">x:Class</span>
              <span style="color: #0000ff">="AnimationSample.Page"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">xmlns</span>
              <span style="color: #0000ff">="http://schemas.microsoft.com/client/2007"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #ff0000">xmlns:x</span>
              <span style="color: #0000ff">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">Width</span>
              <span style="color: #0000ff">="300"</span>
              <span style="color: #ff0000">Height</span>
              <span style="color: #0000ff">="150"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Grid</span>
              <span style="color: #ff0000">x:Name</span>
              <span style="color: #0000ff">="LayoutRoot"</span>
              <span style="color: #ff0000">Background</span>
              <span style="color: #0000ff">="White"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Grid.Triggers</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">EventTrigger</span>
              <span style="color: #ff0000">RoutedEvent</span>
              <span style="color: #0000ff">="Grid.Loaded"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">EventTrigger.Actions</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">BeginStoryboard</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Storyboard</span>
              <span style="color: #ff0000">x:Name</span>
              <span style="color: #0000ff">="CrawlingBorder"</span>
              <span style="color: #ff0000">RepeatBehavior</span>
              <span style="color: #0000ff">="Forever"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">DoubleAnimationUsingKeyFrames</span>
              <span style="color: #ff0000">Storyboard</span>.<span style="color: #ff0000">TargetName</span><span style="color: #0000ff">="rectangle"</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">Storyboard</span>.<span style="color: #ff0000">TargetProperty</span><span style="color: #0000ff">="(Shape.StrokeDashOffset)"</span><span style="color: #ff0000">BeginTime</span><span style="color: #0000ff">="00:00:00"</span><span style="color: #0000ff">&gt;</span></pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">SplineDoubleKeyFrame</span>
              <span style="color: #ff0000">KeyTime</span>
              <span style="color: #0000ff">="00:00:00"</span>
              <span style="color: #ff0000">Value</span>
              <span style="color: #0000ff">="0"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">SplineDoubleKeyFrame</span>
              <span style="color: #ff0000">KeyTime</span>
              <span style="color: #0000ff">="00:00:00.5000000"</span>
              <span style="color: #ff0000">Value</span>
              <span style="color: #0000ff">="5"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">DoubleAnimationUsingKeyFrames</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Storyboard</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">BeginStoryboard</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">EventTrigger.Actions</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">EventTrigger</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Grid.Triggers</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">Rectangle</span>
              <span style="color: #ff0000">Stroke</span>
              <span style="color: #0000ff">="Green"</span>
              <span style="color: #ff0000">StrokeThickness</span>
              <span style="color: #0000ff">="6"</span>
              <span style="color: #ff0000">StrokeDashArray</span>
              <span style="color: #0000ff">="3,2"</span>
              <span style="color: #ff0000">StrokeDashCap</span>
              <span style="color: #0000ff">="Round"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">Margin</span>
              <span style="color: #0000ff">="20"</span>
              <span style="color: #ff0000">StrokeDashOffset</span>
              <span style="color: #0000ff">="0"</span>
              <span style="color: #ff0000">StrokeLineJoin</span>
              <span style="color: #0000ff">="Round"</span>
              <span style="color: #ff0000">x:Name</span>
              <span style="color: #0000ff">="rectangle"</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Rectangle</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;</span>
              <span style="color: #800000">TextBlock</span>
              <span style="color: #ff0000">FontFamily</span>
              <span style="color: #0000ff">="Lucida
Sans Unicode"</span>
              <span style="color: #ff0000">FontSize</span>
              <span style="color: #0000ff">="24"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #ff0000">Text</span>
              <span style="color: #0000ff">="Crawling
Border"</span>
              <span style="color: #ff0000">FontWeight</span>
              <span style="color: #0000ff">="Bold"</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #ff0000">HorizontalAlignment</span>
              <span style="color: #0000ff">="Center"</span>
              <span style="color: #ff0000">VerticalAlignment</span>
              <span style="color: #0000ff">="Center"</span>
              <span style="color: #ff0000">Foreground</span>
              <span style="color: #0000ff">="#FFDE680A"</span>
              <span style="color: #0000ff">/&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">Grid</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
            <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
              <span style="color: #0000ff">&lt;/</span>
              <span style="color: #800000">UserControl</span>
              <span style="color: #0000ff">&gt;</span>
            </pre>
          </div>
        </div>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=c41366fc-ccb3-4d12-8431-b355e6c4b39f" />
      </body>
      <title>Crawling Border Animation</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</guid>
      <link>http://programwith.net/2008/04/22/CrawlingBorderAnimation.aspx</link>
      <pubDate>Tue, 22 Apr 2008 02:55:36 GMT</pubDate>
      <description>&lt;p&gt;
This is a very simple animation that can be used just about anywhere.
&lt;/p&gt;
&lt;p&gt;
&lt;iframe style="width: 300px; height: 150px" src="http://silverlight.services.live.com/invoke/63993/Crawling%20Border/iframe.html" frameborder="0" scrolling="no"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
&lt;p&gt;
[[ If you're viewing this post through an RSS reader, you won't be able to see the
Silverlight example ]]
&lt;/p&gt;
&lt;p&gt;
Following is my Page.xaml for this example.&amp;nbsp; There was no code needed.
&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="AnimationSample.Page"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="300"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Height&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="150"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="LayoutRoot"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="White"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid.Triggers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger&lt;/span&gt; &lt;span style="color: #ff0000"&gt;RoutedEvent&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Grid.Loaded"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger.Actions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Storyboard&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="CrawlingBorder"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;RepeatBehavior&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Forever"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;              &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Storyboard&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;TargetName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="rectangle"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                &lt;span style="color: #ff0000"&gt;Storyboard&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;TargetProperty&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="(Shape.StrokeDashOffset)"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;BeginTime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="00:00:00"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SplineDoubleKeyFrame&lt;/span&gt; &lt;span style="color: #ff0000"&gt;KeyTime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="00:00:00"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="0"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SplineDoubleKeyFrame&lt;/span&gt; &lt;span style="color: #ff0000"&gt;KeyTime&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="00:00:00.5000000"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="5"&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;              &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;DoubleAnimationUsingKeyFrames&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Storyboard&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;          &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;BeginStoryboard&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger.Actions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;      &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;EventTrigger&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid.Triggers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Rectangle&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Stroke&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Green"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeThickness&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="6"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeDashArray&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="3,2"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeDashCap&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Round"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;               &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="20"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeDashOffset&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="0"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;StrokeLineJoin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Round"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="rectangle"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Rectangle&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;TextBlock&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FontFamily&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Lucida
Sans Unicode"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FontSize&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="24"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;               &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Crawling
Border"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;FontWeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Bold"&lt;/span&gt; &lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;               &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Center"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Center"&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Foreground&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="#FFDE680A"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;  &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=c41366fc-ccb3-4d12-8431-b355e6c4b39f" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,c41366fc-ccb3-4d12-8431-b355e6c4b39f.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=92aeb18f-3f9e-452a-9331-d0ee6e99e33c</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=92aeb18f-3f9e-452a-9331-d0ee6e99e33c</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I gave a talk at the <a href="http://cinnug.org/cododn/">Central Ohio Day of .NET</a> last
Saturday about Silverlight 2.  The presentation was written in Silverlight 2
Beta 1 and included examples of functionality built into Silverlight versions 1 and
2, and the beginning steps in creating the presentation itself.
</p>
        <p>
I have much more planned to be added to the presentation, so I created a CodePlex
project called <a href="http://www.codeplex.com/PresentLight">PresentLight</a>. 
I'm hoping that other people will like the idea of giving a presentation in the technology
that they're speaking about, and maybe they'll use the framework or even add their
own content!
</p>
        <p>
I uploaded a slightly older version than the one I gave at CODoDN to silverlight.live.com,
check it out by clicking on the following preview image.  The XAP is 14 MB so
expect a decent wait for everything to load ... I need to reduce the size.  I'll
update this post with a better example as soon as I have it available.
</p>
        <p>
          <a href="http://silverlight.services.live.com/invoke/63993/PresentLight/iframe.html">
            <img height="325" src="http://programwith.net/images/PresentLightSS.png" width="443" />
          </a>
        </p>
        <p>
Much thanks goes out to <a href="http://www.jeffblankenburg.com/index.html">Jeff Blankenburg</a> for
building the original slide deck that I based this presentation on.  Also, I
got the idea from <a href="http://david.sleeckx.be/?p=12">David Sleeckx</a>'s WPF
presentation, which is an excellent way to get an overview of WPF.
</p>
        <h3>Using the Presentation
</h3>
        <p>
You can navigate the slides through the menu on the left, or move forward one slide
by clicking on the header area.  A few of the slides don't have much at first,
but clicking in the slide area will show text which was talking points for that part
of the presentation.  The interactive slides in the middle should be pretty self
explanatory - you can modify the XAML in most of the examples to see changes in real
time.
</p>
        <p>
The screen shots at the end can be clicked on to view the full size.  I wanted
to keep the entire presentation in Silverlight, so I was trying to use screen shots
instead of jumping into Visual Studio.  These slides were taking over an hour
each to prepare, because I was trying to give each one a different type of animation. 
I think they ended up being a little disjointed though - its much more natural to
see someone working with the environment than seeing screen shots of some code, then
the solution explorer, then XAML.  I'm definitely going to have to give more
thought to that area.
</p>
        <h3>Plans for the Future
</h3>
        <p>
I plan to have the slides stored in data rather than hard coded in the page code behind. 
I'm going to integrate more examples, such as Isolated Storage, Communications with
web services and through sockets, and dynamic languages integrated directly into the
slides, like I did with the XAML examples.
</p>
        <p>
Also, I'm going to expand more on some of the user controls that I created as part
of the application.  I already went into the scrolling textbox control in my
last post, so there will be more of that on the way.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=92aeb18f-3f9e-452a-9331-d0ee6e99e33c" />
      </body>
      <title>PresentLight - A Silverlight Presentation Written in Silverlight</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</guid>
      <link>http://programwith.net/2008/04/22/PresentLightASilverlightPresentationWrittenInSilverlight.aspx</link>
      <pubDate>Tue, 22 Apr 2008 02:15:26 GMT</pubDate>
      <description>&lt;p&gt;
I gave a talk at the &lt;a href="http://cinnug.org/cododn/"&gt;Central Ohio Day of .NET&lt;/a&gt; last
Saturday about Silverlight 2.&amp;nbsp; The presentation was written in Silverlight 2
Beta 1 and included examples of functionality built into Silverlight versions 1 and
2, and the beginning steps in creating the presentation itself.
&lt;/p&gt;
&lt;p&gt;
I have much more planned to be added to the presentation, so I created a CodePlex
project called &lt;a href="http://www.codeplex.com/PresentLight"&gt;PresentLight&lt;/a&gt;.&amp;nbsp;
I'm hoping that other people will like the idea of giving a presentation in the technology
that they're speaking about, and maybe they'll use the framework or even add their
own content!
&lt;/p&gt;
&lt;p&gt;
I uploaded a slightly older version than the one I gave at CODoDN to silverlight.live.com,
check it out by clicking on the following preview image.&amp;nbsp; The XAP is 14 MB so
expect a decent wait for everything to load ... I need to reduce the size.&amp;nbsp; I'll
update this post with a better example as soon as I have it available.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://silverlight.services.live.com/invoke/63993/PresentLight/iframe.html"&gt;&lt;img height="325" src="http://programwith.net/images/PresentLightSS.png" width="443"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Much thanks goes out to &lt;a href="http://www.jeffblankenburg.com/index.html"&gt;Jeff Blankenburg&lt;/a&gt; for
building the original slide deck that I based this presentation on.&amp;nbsp; Also, I
got the idea from &lt;a href="http://david.sleeckx.be/?p=12"&gt;David Sleeckx&lt;/a&gt;'s WPF
presentation, which is an excellent way to get an overview of WPF.
&lt;/p&gt;
&lt;h3&gt;Using the Presentation
&lt;/h3&gt;
&lt;p&gt;
You can navigate the slides through the menu on the left, or move forward one slide
by clicking on the header area.&amp;nbsp; A few of the slides don't have much at first,
but clicking in the slide area will show text which was talking points for that part
of the presentation.&amp;nbsp; The interactive slides in the middle should be pretty self
explanatory - you can modify the XAML in most of the examples to see changes in real
time.
&lt;/p&gt;
&lt;p&gt;
The screen shots at the end can be clicked on to view the full size.&amp;nbsp; I wanted
to keep the entire presentation in Silverlight, so I was trying to use screen shots
instead of jumping into Visual Studio.&amp;nbsp; These slides were taking over an hour
each to prepare, because I was trying to give each one a different type of animation.&amp;nbsp;
I think they ended up being a little disjointed though - its much more natural to
see someone working with the environment than seeing screen shots of some code, then
the solution explorer, then XAML.&amp;nbsp; I'm definitely going to have to give more
thought to that area.
&lt;/p&gt;
&lt;h3&gt;Plans for the Future
&lt;/h3&gt;
&lt;p&gt;
I plan to have the slides stored in data rather than hard coded in the page code behind.&amp;nbsp;
I'm going to integrate more examples, such as Isolated Storage, Communications with
web services and through sockets, and dynamic languages integrated directly into the
slides, like I did with the XAML examples.
&lt;/p&gt;
&lt;p&gt;
Also, I'm going to expand more on some of the user controls that I created as part
of the application.&amp;nbsp; I already went into the scrolling textbox control in my
last post, so there will be more of that on the way.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=92aeb18f-3f9e-452a-9331-d0ee6e99e33c" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,92aeb18f-3f9e-452a-9331-d0ee6e99e33c.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=470085fe-abab-4091-a93f-d5d77fb8ecfc</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=470085fe-abab-4091-a93f-d5d77fb8ecfc</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox(VS.95).aspx">TextBox</a> control
included with Silverlight 2 Beta 1 is a welcome addition.  There was no such
control in previous versions of Silverlight, including the alpha.
</p>
        <p>
Unfortunately, the TextBox control is very limited at this point.  It does not
support scrollbars when it's content is larger than it's size.  You can "scroll"
the next by moving the cursor, but that's just enough to make it functional. 
Selecting text past what's visible doesn't automatically scroll to the cursor. 
Also, there's no text wrapping, although setting the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.acceptsreturn(VS.95).aspx">AcceptsReturn</a> property
to True will allow line breaks in the text.
</p>
        <p>
I wanted to have a text box with a little more functionality for my projects, so I
decided to see what I could do.  What follows is the simple ScrollingTextBox
control that I created.  I didn't spend a ton of time on this because I fully
expect this "missing" functionality to be included by Beta 2, or at least by the time
Silverlight 2 is released.
</p>
        <iframe src="http://silverlight.services.live.com/invoke/63993/Scrolling%20TextBox%20Control/iframe.html" scrolling="no" frameborder="0" style="width:400px; height:300px">
        </iframe>
        <p>
 
</p>
        <p>
To build this, I first created a Silverlight application project and added a Silverlight
control called ScrollingTextBox.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">UserControl</span>
          <span class="attr">x:Class</span>
          <span class="kwrd">="PresentLight.ScrollingTextBox"</span>
          <span class="attr">xmlns</span>
          <span class="kwrd">="http://schemas.microsoft.com/client/2007"</span>
          <span class="attr">xmlns:x</span>
          <span class="kwrd">="http://schemas.microsoft.com/winfx/2006/xaml"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Grid</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="LayoutRoot"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ScrollViewer</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="sv"</span>
          <span class="attr">HorizontalScrollBarVisibility</span>
          <span class="kwrd">="Auto"</span>
          <span class="attr">VerticalScrollBarVisibility</span>
          <span class="kwrd">="Auto"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="hiddenTextBlock"</span>
          <span class="attr">Opacity</span>
          <span class="kwrd">="0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBox</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="tb"</span>
          <span class="attr">AcceptsReturn</span>
          <span class="kwrd">="True"</span>
          <span class="attr">TextChanged</span>
          <span class="kwrd">="tb_TextChanged"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ScrollViewer</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Grid</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">UserControl</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.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>
        <p>
The internal <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textblock(VS.95).aspx">TextBlock</a> control
is only there to serve as a way to get the actual size of the text.  TextBlock
controls will automatically resize to fit their contents, so if I keep it's text the
same as the internal textbox control, it will resize accordingly.  The default
value for <a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.width(VS.95).aspx">Width</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.height(VS.95).aspx">Height</a> dependency
properties in Silverlight is Auto, which causes this resize behavior.
</p>
        <p>
Since the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.scrollviewer(VS.95).aspx">ScrollViewer</a> control
automatically set's it's scrollable region to fit it's contents, it will be resized
to fit the internal textblock.  The internal textbox control will automatically
resize to fit it's container, since I haven't set any width or height on it.
</p>
        <p>
Then I added a dependency property for setting the control's Text, which takes care
of setting the textbox's text value.  Finally, I handled the <a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.textchanged(VS.95).aspx">TextChanged</a> event
on the internal TextBox control to resize based on my internal TextBlock's size.
</p>
        <pre class="csharpcode">
          <span class="kwrd">using</span> System.Windows; <span class="kwrd">using</span> System.Windows.Controls; <span class="kwrd">namespace</span> PresentLight
{ <span class="kwrd">public</span><span class="kwrd">partial</span><span class="kwrd">class</span> ScrollingTextBox
: UserControl { <span class="kwrd">public</span><span class="kwrd">string</span> Text
{ get { <span class="kwrd">return</span> (<span class="kwrd">string</span>)GetValue(TextProperty);
} set { SetValue(TextProperty, <span class="kwrd">value</span>); tb.Text = <span class="kwrd">value</span>;
} } <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">readonly</span> DependencyProperty
TextProperty = DependencyProperty.Register(<span class="str">"Text"</span>, <span class="kwrd">typeof</span>(<span class="kwrd">string</span>), <span class="kwrd">typeof</span>(ScrollingTextBox), <span class="kwrd">null</span>); <span class="kwrd">public</span> ScrollingTextBox()
{ InitializeComponent(); } <span class="kwrd">private</span><span class="kwrd">void</span> tb_TextChanged(<span class="kwrd">object</span> sender,
TextChangedEventArgs e) { <span class="kwrd">if</span> (hiddenTextBlock != <span class="kwrd">null</span>)
{ hiddenTextBlock.Text = tb.Text; tb.Width = hiddenTextBlock.ActualWidth; tb.Height
= hiddenTextBlock.ActualHeight; } } } }</pre>
        <style type="text/css">.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>
        <p>
The result is a marginally better control.  There are a lot of possible improvements
for me to make, such as possibly handing the selection changed event on the textbox
to scroll the ScrollViewer to the cursor's position.  That will have to wait
for a future post.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=470085fe-abab-4091-a93f-d5d77fb8ecfc" />
      </body>
      <title>Scrolling TextBox in Silverlight 2 Beta 1</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</guid>
      <link>http://programwith.net/2008/04/13/ScrollingTextBoxInSilverlight2Beta1.aspx</link>
      <pubDate>Sun, 13 Apr 2008 14:41:18 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox(VS.95).aspx"&gt;TextBox&lt;/a&gt; control
included with Silverlight 2 Beta 1 is a welcome addition.&amp;nbsp; There was no such
control in previous versions of Silverlight, including the alpha.
&lt;/p&gt;
&lt;p&gt;
Unfortunately, the TextBox control is very limited at this point.&amp;nbsp; It does not
support scrollbars when it's content is larger than it's size.&amp;nbsp; You can "scroll"
the next by moving the cursor, but that's just enough to make it functional.&amp;nbsp;
Selecting text past what's visible doesn't automatically scroll to the cursor.&amp;nbsp;
Also, there's no text wrapping, although setting the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.acceptsreturn(VS.95).aspx"&gt;AcceptsReturn&lt;/a&gt; property
to True will allow line breaks in the text.
&lt;/p&gt;
&lt;p&gt;
I wanted to have a text box with a little more functionality for my projects, so I
decided to see what I could do.&amp;nbsp; What follows is the simple ScrollingTextBox
control that I created.&amp;nbsp; I didn't spend a ton of time on this because I fully
expect this "missing" functionality to be included by Beta 2, or at least by the time
Silverlight 2 is released.
&lt;/p&gt;
&lt;iframe src="http://silverlight.services.live.com/invoke/63993/Scrolling%20TextBox%20Control/iframe.html" scrolling="no" frameborder="0" style="width:400px; height:300px"&gt;
&lt;/iframe&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
To build this, I first created a Silverlight application project and added a Silverlight
control called ScrollingTextBox.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="PresentLight.ScrollingTextBox"&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/client/2007"&lt;/span&gt; &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LayoutRoot"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="sv"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt; &lt;span class="attr"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span class="kwrd"&gt;="Auto"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="hiddenTextBlock"&lt;/span&gt; &lt;span class="attr"&gt;Opacity&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBox&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="tb"&lt;/span&gt; &lt;span class="attr"&gt;AcceptsReturn&lt;/span&gt;&lt;span class="kwrd"&gt;="True"&lt;/span&gt; &lt;span class="attr"&gt;TextChanged&lt;/span&gt;&lt;span class="kwrd"&gt;="tb_TextChanged"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ScrollViewer&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Grid&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;p&gt;
The internal &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textblock(VS.95).aspx"&gt;TextBlock&lt;/a&gt; control
is only there to serve as a way to get the actual size of the text.&amp;nbsp; TextBlock
controls will automatically resize to fit their contents, so if I keep it's text the
same as the internal textbox control, it will resize accordingly.&amp;nbsp; The default
value for &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.width(VS.95).aspx"&gt;Width&lt;/a&gt; and &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.frameworkelement.height(VS.95).aspx"&gt;Height&lt;/a&gt; dependency
properties in Silverlight is Auto, which causes this resize behavior.
&lt;/p&gt;
&lt;p&gt;
Since the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.scrollviewer(VS.95).aspx"&gt;ScrollViewer&lt;/a&gt; control
automatically set's it's scrollable region to fit it's contents, it will be resized
to fit the internal textblock.&amp;nbsp; The internal textbox control will automatically
resize to fit it's container, since I haven't set any width or height on it.
&lt;/p&gt;
&lt;p&gt;
Then I added a dependency property for setting the control's Text, which takes care
of setting the textbox's text value.&amp;nbsp; Finally, I handled the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.textbox.textchanged(VS.95).aspx"&gt;TextChanged&lt;/a&gt; event
on the internal TextBox control to resize based on my internal TextBlock's size.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows; &lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Controls; &lt;span class="kwrd"&gt;namespace&lt;/span&gt; PresentLight
{ &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ScrollingTextBox
: UserControl { &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Text
{ get { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt;)GetValue(TextProperty);
} set { SetValue(TextProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;); tb.Text = &lt;span class="kwrd"&gt;value&lt;/span&gt;;
} } &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; DependencyProperty
TextProperty = DependencyProperty.Register(&lt;span class="str"&gt;"Text"&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;string&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ScrollingTextBox), &lt;span class="kwrd"&gt;null&lt;/span&gt;); &lt;span class="kwrd"&gt;public&lt;/span&gt; ScrollingTextBox()
{ InitializeComponent(); } &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; tb_TextChanged(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
TextChangedEventArgs e) { &lt;span class="kwrd"&gt;if&lt;/span&gt; (hiddenTextBlock != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
{ hiddenTextBlock.Text = tb.Text; tb.Width = hiddenTextBlock.ActualWidth; tb.Height
= hiddenTextBlock.ActualHeight; } } } }&lt;/pre&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;p&gt;
The result is a marginally better control.&amp;nbsp; There are a lot of possible improvements
for me to make, such as possibly handing the selection changed event on the textbox
to scroll the ScrollViewer to the cursor's position.&amp;nbsp; That will have to wait
for a future post.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=470085fe-abab-4091-a93f-d5d77fb8ecfc" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,470085fe-abab-4091-a93f-d5d77fb8ecfc.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=685207f7-56f7-4aa3-a10a-9d8eac1e7042</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=685207f7-56f7-4aa3-a10a-9d8eac1e7042</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I haven't been posting much lately because I've been very busy preparing for my <a href="http://cinnug.org/cododn/sessions.aspx#Creating%20Silverlight%202.0%20Presentation%20in%20Silverlight%202.0">session</a> at
the <a href="http://cinnug.org/cododn/">Central Ohio Day of .NET</a>.  I'm creating
a presentation about Silverlight 2.0 Beta 1, but with a <a href="http://www.youtube.com/watch?v=cWWtb2uDDfE">twist</a> -
the presentation is actually a Silverlight application!
</p>
        <h4>Templates
</h4>
        <p>
For the last day or so I've been working on getting my application's main control
to use templates to define the interface.  This gives me the option to create
multiple "skins" for the application.
</p>
        <p>
To accomplish this, I've been referencing two very excellent tutorials by <a href="http://silverlight.net/learn/tutorials/stylestemplates.aspx">Jesse
Liberty</a> and <a href="http://blogs.msdn.com/sburke/archive/2008/03/22/tutorial-writing-a-templated-silverlight-2-control.aspx">Shawn
Burke</a>.  But, as usual for me, I ran into a problem that sucked up a ton of
time.
</p>
        <h4>The Problem
</h4>
        <p>
I was trying to set up my template to include buttons for navigation between slides. 
I started by building a simple XAML interface for the buttons, like so.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">StackPanel</span>
          <span class="attr">Orientation</span>
          <span class="kwrd">="Horizontal"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="First"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Prev"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Next"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Last"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">StackPanel</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.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>
        <p>
 
</p>
        <p>
And that looks good enough for this example.
</p>
        <p>
          <img src="http://programwith.net/images/TemplateExample1.png" />  
</p>
        <p>
Then I took that same XAML and put it into a template stored in the application resources
(in App.xaml).
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Style</span>
          <span class="attr">x:Key</span>
          <span class="kwrd">="TestTemplate"</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter</span>
          <span class="attr">Property</span>
          <span class="kwrd">="Template"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ControlTemplate</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">StackPanel</span>
          <span class="attr">Orientation</span>
          <span class="kwrd">="Horizontal"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="First"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Prev"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Next"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">TextBlock</span>
          <span class="attr">Text</span>
          <span class="kwrd">="Last"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">StackPanel</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ControlTemplate</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Style</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.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>
        <style type="text/css">.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>
        <p>
And modified my Page.xaml to have my Presentation UserControl class (modeled after
Shawn Burke's tutorial) with the template applied as a style.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">local:Presentation</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="PresentationControl"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestTemplate}"</span>
          <span class="kwrd">/&gt;</span>
          <style type="text/css">.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>
        </pre>
        <p>
But running this treated me to a browser window that's stuck loading.  My break
point in OnApplyTemplate in my Presentation class never got hit.  Pausing Visual
Studio didn't tell me anything, so I knew it wasn't stuck in a loop.  This had
me stuck for several hours.
</p>
        <h4>The Solution
</h4>
        <p>
What I eventually found was that certain things that are perfectly acceptable XAML
in a user control won't work in a template.  Furthermore, if Silverlight encounters
these elements in the template it just hangs.
</p>
        <p>
The problem XAML was the buttons.  Instead of including your actual buttons in
your template, you should instead create a separate template for the buttons, and
reference that as your button style.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">Style</span>
          <span class="attr">x:Key</span>
          <span class="kwrd">="TestButton"</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="Button"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter</span>
          <span class="attr">Property</span>
          <span class="kwrd">="Template"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ControlTemplate</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="Button"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">Width</span>
          <span class="kwrd">="75"</span>
          <span class="attr">Height</span>
          <span class="kwrd">="75"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button.Content</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ContentPresenter</span>
          <span class="attr">Content</span>
          <span class="kwrd">="{TemplateBinding
Content}"</span>
          <span class="attr">HorizontalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="attr">VerticalAlignment</span>
          <span class="kwrd">="Center"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button.Content</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Button</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ControlTemplate</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Style</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <p>
Then modify the previous template to use the new button template.
</p>
        <pre class="csharpcode">
          <span class="kwrd">&lt;</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Style</span>
          <span class="attr">x:Key</span>
          <span class="kwrd">="TestTemplate"</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter</span>
          <span class="attr">Property</span>
          <span class="kwrd">="Template"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">ControlTemplate</span>
          <span class="attr">TargetType</span>
          <span class="kwrd">="pl:Presentation"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">StackPanel</span>
          <span class="attr">Orientation</span>
          <span class="kwrd">="Horizontal"</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="FirstButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="First"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="PreviousButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="Prev"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="NextButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="Next"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="attr">Margin</span>
          <span class="kwrd">="0,0,8,0"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;</span>
          <span class="html">Button</span>
          <span class="attr">x:Name</span>
          <span class="kwrd">="LastButtonElement"</span>
          <span class="attr">Content</span>
          <span class="kwrd">="Last"</span>
          <span class="attr">Style</span>
          <span class="kwrd">="{StaticResource
TestButton}"</span>
          <span class="kwrd">/&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">StackPanel</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">ControlTemplate</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter.Value</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Setter</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Style</span>
          <span class="kwrd">&gt;</span>
          <span class="kwrd">&lt;/</span>
          <span class="html">Application.Resources</span>
          <span class="kwrd">&gt;</span>
        </pre>
        <style type="text/css">.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>
        <p>
Finally, this works.  It looks the same, but now I can take the template and
make it look much nicer if I want.
</p>
        <p>
Hopefully this tip will help others working on templating in Silverlight avoid the
pitfalls I ran into.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=685207f7-56f7-4aa3-a10a-9d8eac1e7042" />
      </body>
      <title>Silverlight Templates Tip</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</guid>
      <link>http://programwith.net/2008/04/12/SilverlightTemplatesTip.aspx</link>
      <pubDate>Sat, 12 Apr 2008 22:45:08 GMT</pubDate>
      <description>&lt;p&gt;
I haven't been posting much lately because I've been very busy preparing for my &lt;a href="http://cinnug.org/cododn/sessions.aspx#Creating%20Silverlight%202.0%20Presentation%20in%20Silverlight%202.0"&gt;session&lt;/a&gt; at
the &lt;a href="http://cinnug.org/cododn/"&gt;Central Ohio Day of .NET&lt;/a&gt;.&amp;nbsp; I'm creating
a presentation about Silverlight 2.0 Beta 1, but with a &lt;a href="http://www.youtube.com/watch?v=cWWtb2uDDfE"&gt;twist&lt;/a&gt; -
the presentation is actually a Silverlight application!
&lt;/p&gt;
&lt;h4&gt;Templates
&lt;/h4&gt;
&lt;p&gt;
For the last day or so I've been working on getting my application's main control
to use templates to define the interface.&amp;nbsp; This gives me the option to create
multiple "skins" for the application.
&lt;/p&gt;
&lt;p&gt;
To accomplish this, I've been referencing two very excellent tutorials by &lt;a href="http://silverlight.net/learn/tutorials/stylestemplates.aspx"&gt;Jesse
Liberty&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/sburke/archive/2008/03/22/tutorial-writing-a-templated-silverlight-2-control.aspx"&gt;Shawn
Burke&lt;/a&gt;.&amp;nbsp; But, as usual for me, I ran into a problem that sucked up a ton of
time.
&lt;/p&gt;
&lt;h4&gt;The Problem
&lt;/h4&gt;
&lt;p&gt;
I was trying to set up my template to include buttons for navigation between slides.&amp;nbsp;
I started by building a simple XAML interface for the buttons, like so.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="First"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Prev"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Next"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Last"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
And that looks good enough for this example.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://programwith.net/images/TemplateExample1.png"&gt;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Then I took that same XAML and put it into a template stored in the application resources
(in App.xaml).
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TestTemplate"&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Template"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="First"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Prev"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Next"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;="Last"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;p&gt;
And modified my Page.xaml to have my Presentation UserControl class (modeled after
Shawn Burke's tutorial) with the template applied as a style.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;local:Presentation&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="PresentationControl"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestTemplate}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;/pre&gt;
&lt;p&gt;
But running this treated me to a browser window that's stuck loading.&amp;nbsp; My break
point in OnApplyTemplate in my Presentation class never got hit.&amp;nbsp; Pausing Visual
Studio didn't tell me anything, so I knew it wasn't stuck in a loop.&amp;nbsp; This had
me stuck for several hours.
&lt;/p&gt;
&lt;h4&gt;The Solution
&lt;/h4&gt;
&lt;p&gt;
What I eventually found was that certain things that are perfectly acceptable XAML
in a user control won't work in a template.&amp;nbsp; Furthermore, if Silverlight encounters
these elements in the template it just hangs.
&lt;/p&gt;
&lt;p&gt;
The problem XAML was the buttons.&amp;nbsp; Instead of including your actual buttons in
your template, you should instead create a separate template for the buttons, and
reference that as your button style.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TestButton"&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="Button"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Template"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="Button"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;Width&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="75"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ContentPresenter&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="{TemplateBinding
Content}"&lt;/span&gt; &lt;span class="attr"&gt;HorizontalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="attr"&gt;VerticalAlignment&lt;/span&gt;&lt;span class="kwrd"&gt;="Center"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button.Content&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Then modify the previous template to use the new button template.
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;="TestTemplate"&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt; &lt;span class="attr"&gt;Property&lt;/span&gt;&lt;span class="kwrd"&gt;="Template"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt; &lt;span class="attr"&gt;TargetType&lt;/span&gt;&lt;span class="kwrd"&gt;="pl:Presentation"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt; &lt;span class="attr"&gt;Orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="Horizontal"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="FirstButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="First"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="PreviousButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Prev"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="NextButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Next"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="0,0,8,0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="LastButtonElement"&lt;/span&gt; &lt;span class="attr"&gt;Content&lt;/span&gt;&lt;span class="kwrd"&gt;="Last"&lt;/span&gt; &lt;span class="attr"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;="{StaticResource
TestButton}"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;StackPanel&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;ControlTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter.Value&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Setter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Style&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Application.Resources&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.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; }
&lt;/style&gt;
&lt;p&gt;
Finally, this works.&amp;nbsp; It looks the same, but now I can take the template and
make it look much nicer if I want.
&lt;/p&gt;
&lt;p&gt;
Hopefully this tip will help others working on templating in Silverlight avoid the
pitfalls I ran into.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=685207f7-56f7-4aa3-a10a-9d8eac1e7042" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,685207f7-56f7-4aa3-a10a-9d8eac1e7042.aspx</comments>
      <category>silverlight</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=cb7daf49-dbdb-44f1-9612-218700bf45a7</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,cb7daf49-dbdb-44f1-9612-218700bf45a7.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,cb7daf49-dbdb-44f1-9612-218700bf45a7.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=cb7daf49-dbdb-44f1-9612-218700bf45a7</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In Windows XP's <em>Add/Remove Programs</em> you get information about installed applications
such as copyright, version, last run, etc.  At first glance this information
appears to be gone in Windows Vista's <em>Programs and Features</em>.
</p>
        <h4>Where'd the Program Information Go?
</h4>
        <p>
I was recently <a href="http://programwith.net/2008/03/06/Silverlight2Beta1ToolsWontInstall.aspx">trying
to figure out the version of Silverlight that I have installed</a>, but selecting
the item from Programs and Features doesn't tell me anything.  Also, clicking <em>Uninstall</em> immediately
starts the uninstallation without showing me the version, and clicking <em>Change</em> didn't
do anything at all.
</p>
        <p>
I was thinking to myself, "Microsoft wouldn't just remove this information totally
... that would be stupid," so I spent a little more time poking around and found that
you can right click on the column headers, click on More... and get a dialog that
allows you to select other columns to display.
</p>
        <p>
          <img style="border: 0px none ; margin: 0px 0px 0px 25px;" alt="Programs and Features - Choose Columns" src="http://programwith.net/Images/ProgramsAndFeaturesColumns.png" border="0" />
        </p>
        <p>
The information that used to be available by default in Add/Remove Programs is now
displays in these columns.  It sucks that it's apparently hidden from view, but
I guess it didn't take me too long to find it.
</p>
        <h4>Loading
</h4>
        <p>
Another change in Programs and Features is the loading.  Add/Remove Programs
could take a long time to display, but once it did you had everything available. 
Programs and Features loads installed applications bit by bit, and refreshes the screen. 
This is annoying if you've started scrolling down or selected an item before its done
loading, because the refresh causes things to jump around.
</p>
        <p>
While its nice that it loads a lot quicker in Vista, it almost appears to be worse
because it punishes you for trying to use it too quickly.  This reminds me of
how Windows boots a lot more quickly in XP and Vista, but it does more things after
you've logged in so the system really isn't available immediately.  If you click
on the Start menu too quickly it will go away.  Again, punishing you for working
too quickly.
</p>
        <p>
I'd like an OS that keeps up with how fast I want to work.
</p>
        <img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=cb7daf49-dbdb-44f1-9612-218700bf45a7" />
      </body>
      <title>Vista Programs and Features</title>
      <guid isPermaLink="false">http://programwith.net/PermaLink,guid,cb7daf49-dbdb-44f1-9612-218700bf45a7.aspx</guid>
      <link>http://programwith.net/2008/03/07/VistaProgramsAndFeatures.aspx</link>
      <pubDate>Fri, 07 Mar 2008 03:19:08 GMT</pubDate>
      <description>&lt;p&gt;
In Windows XP's &lt;em&gt;Add/Remove Programs&lt;/em&gt; you get information about installed applications
such as copyright, version, last run, etc.&amp;nbsp; At first glance this information
appears to be gone in Windows Vista's &lt;em&gt;Programs and Features&lt;/em&gt;.
&lt;/p&gt;
&lt;h4&gt;Where'd the Program Information Go?
&lt;/h4&gt;
&lt;p&gt;
I was recently &lt;a href="http://programwith.net/2008/03/06/Silverlight2Beta1ToolsWontInstall.aspx"&gt;trying
to figure out the version of Silverlight that I have installed&lt;/a&gt;, but selecting
the item from Programs and Features doesn't tell me anything.&amp;nbsp; Also, clicking &lt;em&gt;Uninstall&lt;/em&gt; immediately
starts the uninstallation without showing me the version, and clicking &lt;em&gt;Change&lt;/em&gt; didn't
do anything at all.
&lt;/p&gt;
&lt;p&gt;
I was thinking to myself, "Microsoft wouldn't just remove this information totally
... that would be stupid," so I spent a little more time poking around and found that
you can right click on the column headers, click on More... and get a dialog that
allows you to select other columns to display.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border: 0px none ; margin: 0px 0px 0px 25px;" alt="Programs and Features - Choose Columns" src="http://programwith.net/Images/ProgramsAndFeaturesColumns.png" border="0"&gt;
&lt;/p&gt;
&lt;p&gt;
The information that used to be available by default in Add/Remove Programs is now
displays in these columns.&amp;nbsp; It sucks that it's apparently hidden from view, but
I guess it didn't take me too long to find it.
&lt;/p&gt;
&lt;h4&gt;Loading
&lt;/h4&gt;
&lt;p&gt;
Another change in Programs and Features is the loading.&amp;nbsp; Add/Remove Programs
could take a long time to display, but once it did you had everything available.&amp;nbsp;
Programs and Features loads installed applications bit by bit, and refreshes the screen.&amp;nbsp;
This is annoying if you've started scrolling down or selected an item before its done
loading, because the refresh causes things to jump around.
&lt;/p&gt;
&lt;p&gt;
While its nice that it loads a lot quicker in Vista, it almost appears to be worse
because it punishes you for trying to use it too quickly.&amp;nbsp; This reminds me of
how Windows boots a lot more quickly in XP and Vista, but it does more things after
you've logged in so the system really isn't available immediately.&amp;nbsp; If you click
on the Start menu too quickly it will go away.&amp;nbsp; Again, punishing you for working
too quickly.
&lt;/p&gt;
&lt;p&gt;
I'd like an OS that keeps up with how fast I want to work.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://programwith.net/aggbug.ashx?id=cb7daf49-dbdb-44f1-9612-218700bf45a7" /&gt;</description>
      <comments>http://programwith.net/CommentView,guid,cb7daf49-dbdb-44f1-9612-218700bf45a7.aspx</comments>
      <category>misc</category>
    </item>
    <item>
      <trackback:ping>http://programwith.net/Trackback.aspx?guid=a106e915-6b68-46a2-9393-29c87e17695a</trackback:ping>
      <pingback:server>http://programwith.net/pingback.aspx</pingback:server>
      <pingback:target>http://programwith.net/PermaLink,guid,a106e915-6b68-46a2-9393-29c87e17695a.aspx</pingback:target>
      <dc:creator>Matt Casto</dc:creator>
      <wfw:comment>http://programwith.net/CommentView,guid,a106e915-6b68-46a2-9393-29c87e17695a.aspx</wfw:comment>
      <wfw:commentRss>http://programwith.net/SyndicationService.asmx/GetEntryCommentsRss?guid=a106e915-6b68-46a2-9393-29c87e17695a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I arrived at work this morning only to find that the Silverlight 2.0 Beta 1 plugin
and some documentation was discovered and available for download.  A few hours
later the SDK and documentation was available, then after the keynote at Mix that
whole lot was officially released.  I couldn't wait to try it out when I got
home.
</p>
        <p>
Unfortunately, the install experience hasn't been good.  I've got the Silverlight
2.0 plugin and SDK installed, but I can't get the tools for Visual Studio 2008 installed. 
Here's step by step what I've done so far.
</p>
        <ol>
          <li>
Downloaded and installed the Silverlight 2 Beta 1 plugin (runtime) without a hitch.</li>
          <li>
Downloaded Silverlight 2 Beta 1 SDK, Silverlight 2 Beta 1 Tools for Visual Studio
2008, and Expression Blend 2.5 March Preview.</li>
          <li>
Uninstalled Silverlight 1.1 Alpha Tools for Visual Studio 2008 and Expression Blend
2 December Preview.</li>
          <li>
Installed Silverlight 2 Beta 1 SDK.</li>
          <li>
Tried to install Silverlight 2 Beta 1 Tools for Visual Studio but got the following
error message:</li>
        </ol>
        <ol>
        </ol>
        <p>
An Error Has Occurred:<br />
Silverlight Tools cannot be installed because one or more of the following conditions
is true: 
</p>
        <p>
1. Visual Studio 2008 RTM is not installed.<br />
2. The Web Authoring feature of Visual Studio is not installed.<br />
3. A previous version of the Silverlight Runtime is installed.<br />
4. A previous version of the Silverlight SDK is installed.<br />
5. The Visual Studio Update KB949325 is installed.<br />
6. A previous version of Silverlight Tools is installed. 
</p>
        <p>
To continue, please install or uninstall the appropriate products and run this installer
again.
</p>
        <li>
Verified what I had installed.  I've got Visual Studio Team System 2008 RTM,
Microsoft Visual Studio Web Authoring Component, Silverlight runtime, Silverlight
2 SDK, Silverlight 1.0 SDK.  Oops, maybe that's the problem?  Also, I didn't
uninstall Silverlight 1.1 Alpha runtime before installing Silverlight 2.0 runtime,
but that shouldn't be a problem.</li>
        <li>
Uninstalled Silverlight runtime and both SDKs, then rebooted for good measure.</li>
        <li>
Installed Silverlight runtime, 2.0 SDK, ran silverlight_chainer.exe again and got
the same error.</li>
        <li>
Did a web search and found <a title="http://blog.steeleprice.net/archive/2008/03/05/1362.aspx" href="http://blog.steeleprice.net/archive/2008/03/05/1362.aspx">http://blog.steeleprice.net/archive/2008/03/05/1362.aspx</a> which
mentions a registry key that needs to be removed, but I don't have that registry key
on my system.</li>
        <p>
At this point I can't find any more information through web searches or in the Silverlight.Net
forums.  I'm posting this problem in the forums with a link here for a complete
description of the problem.
</p>
        <p>
I was really hoping to get few things done in Silverlight 2.0 and posted online tonight,
but I'm kind of stuck and frustrated at this point.
</p>
        <p>
        </p>
        <h3>UPDATE
</h3>
        <p>
        </p>
        <p>
          <a href="http://cornucopia30.blogspot.com/">Chad Campbell</a> responded to my <a href="http://silverlight.net/forums/t/10719.aspx">Silverlight.net
forum post</a> with a solution.  The solution definitely isn't something that
I'd say is obvious, but hey, do whatever works.  I'm just a little surprised
that I'd have more trouble with the beta than the al