<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Bryant Likes</title>
    <link>http://bryantlikes.com/</link>
    <description>Sharing My Thoughts on Technology</description>
    <image>
      <url>http://files.bryantlikes.com/Images/channel.jpg</url>
      <title>Bryant Likes</title>
      <link>http://bryantlikes.com/</link>
    </image>
    <language>en-us</language>
    <copyright>Bryant Likes</copyright>
    <lastBuildDate>Mon, 18 Jan 2010 18:06:58 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>blog@bryantlikes.com</managingEditor>
    <webMaster>blog@bryantlikes.com</webMaster>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=d8f512f8-1860-49fb-9d26-234aaedacd95</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,d8f512f8-1860-49fb-9d26-234aaedacd95.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,d8f512f8-1860-49fb-9d26-234aaedacd95.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d8f512f8-1860-49fb-9d26-234aaedacd95</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the cool features of SharePoint 2010 (currently in beta) is that you can set
it up on a Windows 7 machine. This means that as a SharePoint developer you no longer
have to run a Server OS. 
</p>
        <p>
To get started I <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=906c9f5a-6505-4eba-bf24-95e423ac1703&amp;displaylang=en">downloaded
the SharePoint 2010 Foundations beta from here</a>. You will also <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx">need
Visual Studio 2010 which you can download from here</a>.
</p>
        <p>
To setup SharePoint 2010 on Windows 7 you need to <a href="http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx">follow
this guide which explains how to configure the setup process to run on Windows 7</a> (it
is only one change to an xml file). 
</p>
        <blockquote>
          <p>
            <em>Make sure you install all the prerequisites which I won’t list here (they are
listed in the guide). It will still install even if you don’t, but you will get errors
when you try to configure SharePoint (voice of experience here).</em>
          </p>
        </blockquote>
        <p>
Once you have everything installed and have completed the configuration tool, your
site should come up in the browser! Now you can start working with Silverlight and
SharePoint.
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb.png" width="644" height="443" />
          </a>
        </p>
        <p>
        </p>
        <blockquote>
          <p>
            <em>Tip: Install the </em>
            <a href="http://www.codeplex.com/SQL2005SrvcMngr/">
              <em>SQL
Service Manager</em>
            </a>
            <em> so that you can turn SQL Server off when you’re not doing
SharePoint development.</em>  
</p>
        </blockquote>
        <p>
A some great resources for getting started with Silverlight and SharePoint 2010 are
the PDC sessions which you can watch for free:
</p>
        <ul>
          <li>
            <a href="http://microsoftpdc.com/Sessions/P09-05">Developer Patterns to Integrate
Microsoft Silverlight 3.0 with Microsoft SharePoint 2010</a>
          </li>
          <li>
            <a href="http://microsoftpdc.com/Sessions/PR07">Developing Solutions for Microsoft
SharePoint Server 2010 Using the Client Object Model</a>
          </li>
        </ul>
        <p>
For this example we will primarily be utilizing the information in the first session
by Paul Stubbs. With SharePoint 2010, Silverlight can live just about anywhere in
the user interface, but this example will be geared toward how simple it is to publish
a Silverlight application to a SharePoint site and use it in a web part. 
</p>
        <p>
Fire up Visual Studio 2010 and create a new Silverlight Application:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_3.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_3.png" width="644" height="404" />
          </a>
        </p>
        <p>
At the prompt asking you if you want to create a web application to host the Silverlight
application uncheck the checkbox. We don’t need to host Silverlight in a separate
web app since SharePoint will be the host. 
</p>
        <p>
In the Silverlight Application, edit the MainPage.xaml to have the following Xaml:
</p>
        <pre class="code">
          <span style="color: blue">&lt;</span>
          <span style="color: #a31515">Grid </span>
          <span style="color: red">x</span>
          <span style="color: blue">:</span>
          <span style="color: red">Name</span>
          <span style="color: blue">="LayoutRoot" </span>
          <span style="color: red">Background</span>
          <span style="color: blue">="PowderBlue"&gt;
&lt;</span>
          <span style="color: #a31515">TextBlock </span>
          <span style="color: red">Text</span>
          <span style="color: blue">="Silverlight
In SharePoint" </span>
          <span style="color: red">TextWrapping</span>
          <span style="color: blue">="Wrap" </span>
          <span style="color: red">FontSize</span>
          <span style="color: blue">="56" </span>
          <span style="color: red">FontWeight</span>
          <span style="color: blue">="Bold"
/&gt; &lt;/</span>
          <span style="color: #a31515">Grid</span>
          <span style="color: blue">&gt;</span>
        </pre>
        <p>
Now let’s add the SharePoint part of the project. Before we add the SharePoint project
though we need to be running Visual Studio as the Administrator. Save your work and
close the solution. Then right click the Visual Studio 2010 shortcut and select Run
As Administrator. Back in the solution, right click the solution and select Add -&gt;
New Project. Select SharePoint –&gt; 2010 as the project type and select an Empty
SharePoint Project:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_4.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_4.png" width="644" height="408" />
          </a>  
</p>
        <blockquote>
          <p>
            <em>If you aren’t running as an Administrator then Visual Studio will tell you that
the project requires elevated permissions in order to run.</em>
          </p>
        </blockquote>
        <p>
The SharePoint customization Wizard dialog will pop up asking if you want to deploy
as a sandboxed solution or a farm solution. Leave the sandboxed solution checked and
click ok. Next, right click on the SharePoint project in the Solution Explorer and
select Add -&gt; New Item. Add a new Module to the project as shown below:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_5.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_5.png" width="644" height="406" />
          </a>
        </p>
        <p>
Now right click the new Module and select Properties. In the Properties window click
in the Project Output References and then click the ellipse button (…). In the Project
Output References dialog click the Add button. Expand the deployment location property
on the new reference then change the Project Name to the Silverlight project name
and the Deployment Type to ElementFile. You should end up with something that looks
like this:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_6.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_6.png" width="644" height="317" />
          </a>
        </p>
        <p>
        </p>
        <p>
Next expand the module we created in the SharePoint project and delete the Sample.txt
file. Then open the Elements.xml file. Edit the file to include the xap file that
will be generated from our Silverlight application:
</p>
        <pre class="code">
          <span style="color: blue">&lt;?</span>
          <span style="color: #a31515">xml </span>
          <span style="color: red">version</span>
          <span style="color: blue">=</span>"<span style="color: blue">1.0</span>" <span style="color: red">encoding</span><span style="color: blue">=</span>"<span style="color: blue">utf-8</span>"<span style="color: blue">?&gt;
&lt;</span><span style="color: #a31515">Elements </span><span style="color: red">xmlns</span><span style="color: blue">=</span>"<span style="color: blue">http://schemas.microsoft.com/sharepoint/</span>"<span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">Module </span><span style="color: red">Name</span><span style="color: blue">=</span>"<span style="color: blue">SilverlightModule</span>"<span style="color: blue">&gt;
&lt;</span><span style="color: #a31515">File </span><span style="color: red">Path</span><span style="color: blue">=</span>"<span style="color: blue">SilverlightModule\SilverlightInSharePoint.xap</span>" <span style="color: red">Url</span><span style="color: blue">=</span>"<span style="color: blue">_catalogs/masterpage/SilverlightInSharePoint.xap</span>" <span style="color: blue">/&gt;
&lt;/</span><span style="color: #a31515">Module</span><span style="color: blue">&gt;
&lt;/</span><span style="color: #a31515">Elements</span><span style="color: blue">&gt; </span></pre>
        <p>
At this point your application is ready to be deployed. Right click the SharePoint
project and select Set as Startup Project and hit F5. Visual Studio will build and
deploy your project to your local SharePoint site and then open it in the browser.
However, at this point our Silverlight application isn’t active in any of the pages.
Let’s add the Silverlight application as a web part in the default page. 
</p>
        <p>
On the SharePoint site click the edit icon then the insert tab, select Web Part, and
choose the Silverlight Web Part in the Media and Content category:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_7.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_7.png" width="644" height="390" />
          </a>
        </p>
        <p>
Click Add and in the Silverlight Web Part dialog enter the value from the Url field
in the Elements.xml file but <strong>add a leading slash</strong>. So for our example
we would enter:
</p>
        <p>
/_catalogs/masterpage/SilverlightInSharePoint.xap
</p>
        <p>
The web part will give you a message that it could not download the xap file. You
can ignore this message and just click the save icon. You will get the Silverlight
application on the web page, but it will look messed up:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_8.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_8.png" width="467" height="484" />
          </a>
        </p>
        <p>
The problem is the default size for the Silverlight Web Part is 400x300 but our text
is bigger than 300. So we need to set the size to be 400x400. Click the drop down
arrow on the top right of the web part and select Edit Web Part. In the web part properties
dialog set the height of the web part to 400 and set the chrome type to None. Click
Ok and you should get a better looking page:
</p>
        <p>
          <a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_9.png">
            <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_9.png" width="637" height="484" />
          </a>
        </p>
        <p>
Congratulations! You’ve now gotten started with Silverlight 3 and SharePoint 2010.
Silverlight development with SharePoint 2010 is much improved in this new version.
Happy SharePointing!
</p>
        <img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=d8f512f8-1860-49fb-9d26-234aaedacd95" />
      </body>
      <title>Getting Started With Silverlight and SharePoint 2010</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,d8f512f8-1860-49fb-9d26-234aaedacd95.aspx</guid>
      <link>http://bryantlikes.com/GettingStartedWithSilverlightAndSharePoint2010.aspx</link>
      <pubDate>Mon, 18 Jan 2010 18:06:58 GMT</pubDate>
      <description>&lt;p&gt;
One of the cool features of SharePoint 2010 (currently in beta) is that you can set
it up on a Windows 7 machine. This means that as a SharePoint developer you no longer
have to run a Server OS. 
&lt;/p&gt;
&lt;p&gt;
To get started I &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=906c9f5a-6505-4eba-bf24-95e423ac1703&amp;amp;displaylang=en"&gt;downloaded
the SharePoint 2010 Foundations beta from here&lt;/a&gt;. You will also &lt;a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx"&gt;need
Visual Studio 2010 which you can download from here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
To setup SharePoint 2010 on Windows 7 you need to &lt;a href="http://msdn.microsoft.com/en-us/library/ee554869(office.14).aspx"&gt;follow
this guide which explains how to configure the setup process to run on Windows 7&lt;/a&gt; (it
is only one change to an xml file). 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;em&gt;Make sure you install all the prerequisites which I won’t list here (they are
listed in the guide). It will still install even if you don’t, but you will get errors
when you try to configure SharePoint (voice of experience here).&lt;/em&gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Once you have everything installed and have completed the configuration tool, your
site should come up in the browser! Now you can start working with Silverlight and
SharePoint.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb.png" width="644" height="443" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;em&gt;Tip: Install the &lt;/em&gt;&lt;a href="http://www.codeplex.com/SQL2005SrvcMngr/"&gt;&lt;em&gt;SQL
Service Manager&lt;/em&gt;&lt;/a&gt;&lt;em&gt; so that you can turn SQL Server off when you’re not doing
SharePoint development.&lt;/em&gt;&amp;#160; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
A some great resources for getting started with Silverlight and SharePoint 2010 are
the PDC sessions which you can watch for free:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://microsoftpdc.com/Sessions/P09-05"&gt;Developer Patterns to Integrate
Microsoft Silverlight 3.0 with Microsoft SharePoint 2010&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://microsoftpdc.com/Sessions/PR07"&gt;Developing Solutions for Microsoft
SharePoint Server 2010 Using the Client Object Model&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
For this example we will primarily be utilizing the information in the first session
by Paul Stubbs. With SharePoint 2010, Silverlight can live just about anywhere in
the user interface, but this example will be geared toward how simple it is to publish
a Silverlight application to a SharePoint site and use it in a web part. 
&lt;/p&gt;
&lt;p&gt;
Fire up Visual Studio 2010 and create a new Silverlight Application:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_3.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_3.png" width="644" height="404" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
At the prompt asking you if you want to create a web application to host the Silverlight
application uncheck the checkbox. We don’t need to host Silverlight in a separate
web app since SharePoint will be the host. 
&lt;/p&gt;
&lt;p&gt;
In the Silverlight Application, edit the MainPage.xaml to have the following Xaml:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;LayoutRoot&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;PowderBlue&amp;quot;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBlock &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Silverlight
In SharePoint&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;TextWrapping&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Wrap&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;FontSize&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;56&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;FontWeight&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Bold&amp;quot;
/&amp;gt; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Now let’s add the SharePoint part of the project. Before we add the SharePoint project
though we need to be running Visual Studio as the Administrator. Save your work and
close the solution. Then right click the Visual Studio 2010 shortcut and select Run
As Administrator. Back in the solution, right click the solution and select Add -&amp;gt;
New Project. Select SharePoint –&amp;gt; 2010 as the project type and select an Empty
SharePoint Project:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_4.png" width="644" height="408" /&gt;&lt;/a&gt;&amp;#160; 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;em&gt;If you aren’t running as an Administrator then Visual Studio will tell you that
the project requires elevated permissions in order to run.&lt;/em&gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The SharePoint customization Wizard dialog will pop up asking if you want to deploy
as a sandboxed solution or a farm solution. Leave the sandboxed solution checked and
click ok. Next, right click on the SharePoint project in the Solution Explorer and
select Add -&amp;gt; New Item. Add a new Module to the project as shown below:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_5.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_5.png" width="644" height="406" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Now right click the new Module and select Properties. In the Properties window click
in the Project Output References and then click the ellipse button (…). In the Project
Output References dialog click the Add button. Expand the deployment location property
on the new reference then change the Project Name to the Silverlight project name
and the Deployment Type to ElementFile. You should end up with something that looks
like this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_6.png" width="644" height="317" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Next expand the module we created in the SharePoint project and delete the Sample.txt
file. Then open the Elements.xml file. Edit the file to include the xap file that
will be generated from our Silverlight application:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #a31515"&gt;xml &lt;/span&gt;&lt;span style="color: red"&gt;version&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;1.0&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;encoding&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;?&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Elements &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;http://schemas.microsoft.com/sharepoint/&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Module &lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;SilverlightModule&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;File &lt;/span&gt;&lt;span style="color: red"&gt;Path&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;SilverlightModule\SilverlightInSharePoint.xap&lt;/span&gt;&amp;quot; &lt;span style="color: red"&gt;Url&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color: blue"&gt;_catalogs/masterpage/SilverlightInSharePoint.xap&lt;/span&gt;&amp;quot; &lt;span style="color: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Module&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Elements&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
At this point your application is ready to be deployed. Right click the SharePoint
project and select Set as Startup Project and hit F5. Visual Studio will build and
deploy your project to your local SharePoint site and then open it in the browser.
However, at this point our Silverlight application isn’t active in any of the pages.
Let’s add the Silverlight application as a web part in the default page. 
&lt;/p&gt;
&lt;p&gt;
On the SharePoint site click the edit icon then the insert tab, select Web Part, and
choose the Silverlight Web Part in the Media and Content category:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_7.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_7.png" width="644" height="390" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Click Add and in the Silverlight Web Part dialog enter the value from the Url field
in the Elements.xml file but &lt;strong&gt;add a leading slash&lt;/strong&gt;. So for our example
we would enter:
&lt;/p&gt;
&lt;p&gt;
/_catalogs/masterpage/SilverlightInSharePoint.xap
&lt;/p&gt;
&lt;p&gt;
The web part will give you a message that it could not download the xap file. You
can ignore this message and just click the save icon. You will get the Silverlight
application on the web page, but it will look messed up:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_8.png" width="467" height="484" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
The problem is the default size for the Silverlight Web Part is 400x300 but our text
is bigger than 300. So we need to set the size to be 400x400. Click the drop down
arrow on the top right of the web part and select Edit Web Part. In the web part properties
dialog set the height of the web part to 400 and set the chrome type to None. Click
Ok and you should get a better looking page:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_9.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://files.bryantlikes.com/Images/GettingStartedWithSilverlightandSharePoi_1000A/image_thumb_9.png" width="637" height="484" /&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Congratulations! You’ve now gotten started with Silverlight 3 and SharePoint 2010.
Silverlight development with SharePoint 2010 is much improved in this new version.
Happy SharePointing!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=d8f512f8-1860-49fb-9d26-234aaedacd95" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,d8f512f8-1860-49fb-9d26-234aaedacd95.aspx</comments>
      <category>SharePoint</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=35268791-0ffb-4708-aeb4-b3bb2d99f837</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,35268791-0ffb-4708-aeb4-b3bb2d99f837.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,35268791-0ffb-4708-aeb4-b3bb2d99f837.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=35268791-0ffb-4708-aeb4-b3bb2d99f837</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A <a href="http://forums.silverlight.net/forums/t/138752.aspx">question came up in
the Silverlight Forums</a> about how to timeout a user when using <a href="http://code.msdn.microsoft.com/RiaServices">.NET
RIA Services</a>. Since I have implemented this before I thought I would share an
approach I used. There might be a better way that is more integrated with the ASP.Net
security, but for now this works.
</p>
        <p>
To start with, you’ll need <a href="http://brad_abrams.members.winisp.net/Projects/Silverlight3RTM/MyApp.LiveSite.zip">the
Sample Application</a> that <a href="http://blogs.msdn.com/brada/archive/2009/10/27/index-for-business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update.aspx">Brad
Abram has been building and blogging about</a> and you might want to read through <a href="http://blogs.msdn.com/brada/archive/2009/07/22/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-6-poco-and-authentication-provider.aspx">this
post on Authentication in RIA Services</a> before going any further. Once you have
that and can build/run it on your machine you can continue on.
</p>
        <p>
The security in Brad’s example uses a simple membership provider that is using RIA
Services FormsAuthentication since it takes a username and password to log in. For
our example we will extend the FormsAuthentication and add a timeout to it. Below
is my implementation of the FormsWithTimeoutAuthentication class:
</p>
        <pre class="code">
          <span style="color: blue">namespace </span>MyApp { <span style="color: blue">public
class </span><span style="color: #2b91af">FormsWithTimeoutAuthentication </span>: <span style="color: #2b91af">FormsAuthentication </span>{ <span style="color: blue">private </span><span style="color: #2b91af">DispatcherTimer </span>idleTimer; <span style="color: blue">private
int </span>minutesIdle; <span style="color: blue">private bool </span>idle; <span style="color: blue">private
bool </span>attached = <span style="color: blue">false</span>; <span style="color: blue">public </span>FormsWithTimeoutAuthentication()
: <span style="color: blue">this</span>(20) { } <span style="color: blue">public </span>FormsWithTimeoutAuthentication(<span style="color: blue">int </span>idleMinutes)
{ IdleMinutesBeforeTimeout = idleMinutes; idleTimer = <span style="color: blue">new </span><span style="color: #2b91af">DispatcherTimer</span>();
idleTimer.Interval = <span style="color: #2b91af">TimeSpan</span>.FromMinutes(1);
idleTimer.Tick += <span style="color: blue">new </span><span style="color: #2b91af">EventHandler</span>(idleTimer_Tick);
} <span style="color: blue">public int </span>IdleMinutesBeforeTimeout { <span style="color: blue">get</span>; <span style="color: blue">set</span>;
} <span style="color: blue">protected override </span><span style="color: #2b91af">LoginResult </span>EndLogin(<span style="color: #2b91af">IAsyncResult </span>asyncResult)
{ <span style="color: blue">var </span>result = <span style="color: blue">base</span>.EndLogin(asyncResult); <span style="color: blue">if </span>(result.LoginSuccess
== <span style="color: blue">true</span>) { <span style="color: blue">if </span>(!attached)
AttachEvents(); minutesIdle = 0; idleTimer.Start(); } <span style="color: blue">return </span>result;
} <span style="color: blue">protected override </span><span style="color: #2b91af">LogoutResult </span>EndLogout(<span style="color: #2b91af">IAsyncResult </span>asyncResult)
{ idleTimer.Stop(); <span style="color: blue">return base</span>.EndLogout(asyncResult);
} <span style="color: blue">private void </span>AttachEvents() { attached = <span style="color: blue">true</span>; <span style="color: #2b91af">Application</span>.Current.RootVisual.MouseMove
+= <span style="color: blue">new </span><span style="color: #2b91af">MouseEventHandler</span>(RootVisual_MouseMove); <span style="color: #2b91af">Application</span>.Current.RootVisual.KeyDown
+= <span style="color: blue">new </span><span style="color: #2b91af">KeyEventHandler</span>(RootVisual_KeyDown);
} <span style="color: blue">private void </span>RootVisual_KeyDown(<span style="color: blue">object </span>sender, <span style="color: #2b91af">KeyEventArgs </span>e)
{ idle = <span style="color: blue">false</span>; } <span style="color: blue">private
void </span>RootVisual_MouseMove(<span style="color: blue">object </span>sender, <span style="color: #2b91af">MouseEventArgs </span>e)
{ idle = <span style="color: blue">false</span>; } <span style="color: blue">private
void </span>idleTimer_Tick(<span style="color: blue">object </span>sender, <span style="color: #2b91af">EventArgs </span>e)
{ <span style="color: blue">if </span>(idle == <span style="color: blue">true</span>)
{ minutesIdle += idleTimer.Interval.Minutes; <span style="color: blue">if </span>(minutesIdle
&gt;= IdleMinutesBeforeTimeout) { Logout(); } } <span style="color: blue">else </span>{
minutesIdle = 0; } idle = <span style="color: blue">true</span>; } } }</pre>
        <p>
All this class does is add a timer that fires once a minute. If the user has either
moved the mouse or hit a key in that minute then they stay logged in. If the user
hasn’t, then a minute of idle time is added to the idle minute count until the timeout
limit is reached. Once that happens the user gets logged out. 
</p>
        <p>
Note that the events are attached to the root visual and don’t get attached until
the user logs in. This is because the Authentication is created prior to the RootVisual
being set. 
</p>
        <p>
Simply add this code to the sample project (linked above) and then change the authentication
service in the App.xaml as follows:
</p>
        <pre class="code">
          <span style="color: blue">&lt;</span>
          <span style="color: #a31515">Application </span>
          <span style="color: red">x</span>
          <span style="color: blue">:</span>
          <span style="color: red">Class</span>
          <span style="color: blue">="MyApp.App" </span>
          <span style="color: red">xmlns</span>
          <span style="color: blue">="http://schemas.microsoft.com/winfx/2006/xaml/presentation" </span>
          <span style="color: red">xmlns</span>
          <span style="color: blue">:</span>
          <span style="color: red">x</span>
          <span style="color: blue">="http://schemas.microsoft.com/winfx/2006/xaml" </span>
          <span style="color: red">xmlns</span>
          <span style="color: blue">:</span>
          <span style="color: red">app</span>
          <span style="color: blue">="clr-namespace:MyApp" </span>
          <span style="color: red">xmlns</span>
          <span style="color: blue">:</span>
          <span style="color: red">appsvc</span>
          <span style="color: blue">="clr-namespace:System.Windows.Ria.ApplicationServices;assembly=System.Windows.Ria"
&gt; &lt;</span>
          <span style="color: #a31515">Application.Resources</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">ResourceDictionary</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">ResourceDictionary.MergedDictionaries</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">ResourceDictionary </span>
          <span style="color: red">Source</span>
          <span style="color: blue">="Assets/Styles.xaml"/&gt;
&lt;/</span>
          <span style="color: #a31515">ResourceDictionary.MergedDictionaries</span>
          <span style="color: blue">&gt;
&lt;/</span>
          <span style="color: #a31515">ResourceDictionary</span>
          <span style="color: blue">&gt;
&lt;/</span>
          <span style="color: #a31515">Application.Resources</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">Application.ApplicationLifetimeObjects</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">app</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">RiaContext</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">app</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">RiaContext.Authentication</span>
          <span style="color: blue">&gt; <strong>&lt;</strong></span>
          <strong>
            <span style="color: #a31515">app</span>
            <span style="color: blue">:</span>
            <span style="color: #a31515">FormsWithTimeoutAuthentication </span>
            <span style="color: red">IdleMinutesBeforeTimeout</span>
          </strong>
          <span style="color: blue">
            <strong>="2"/&gt; </strong>
          </span>
          <span style="color: green">&lt;!--&lt;appsvc:WindowsAuthentication/&gt;--&gt; </span>
          <span style="color: blue">&lt;/</span>
          <span style="color: #a31515">app</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">RiaContext.Authentication</span>
          <span style="color: blue">&gt;
&lt;/</span>
          <span style="color: #a31515">app</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">RiaContext</span>
          <span style="color: blue">&gt;
&lt;/</span>
          <span style="color: #a31515">Application.ApplicationLifetimeObjects</span>
          <span style="color: blue">&gt;
&lt;/</span>
          <span style="color: #a31515">Application</span>
          <span style="color: blue">&gt;</span>
        </pre>
        <p>
Here I’ve set the IdleMinutesBeforeTimeout to 2 minutes so that it is easy to test. 
</p>
        <p>
Once you’ve modified the application, when you run it you will get logged out after
the number of minutes you specify in the timeout. There are lots of enhancements that
could be made to this simple approach, but this works for most situations.
</p>
        <img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=35268791-0ffb-4708-aeb4-b3bb2d99f837" />
      </body>
      <title>Idle Timeouts in RIA Services Authentication</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,35268791-0ffb-4708-aeb4-b3bb2d99f837.aspx</guid>
      <link>http://bryantlikes.com/IdleTimeoutsInRIAServicesAuthentication.aspx</link>
      <pubDate>Wed, 28 Oct 2009 18:02:07 GMT</pubDate>
      <description>&lt;p&gt;
A &lt;a href="http://forums.silverlight.net/forums/t/138752.aspx"&gt;question came up in
the Silverlight Forums&lt;/a&gt; about how to timeout a user when using &lt;a href="http://code.msdn.microsoft.com/RiaServices"&gt;.NET
RIA Services&lt;/a&gt;. Since I have implemented this before I thought I would share an
approach I used. There might be a better way that is more integrated with the ASP.Net
security, but for now this works.
&lt;/p&gt;
&lt;p&gt;
To start with, you’ll need &lt;a href="http://brad_abrams.members.winisp.net/Projects/Silverlight3RTM/MyApp.LiveSite.zip"&gt;the
Sample Application&lt;/a&gt; that &lt;a href="http://blogs.msdn.com/brada/archive/2009/10/27/index-for-business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update.aspx"&gt;Brad
Abram has been building and blogging about&lt;/a&gt; and you might want to read through &lt;a href="http://blogs.msdn.com/brada/archive/2009/07/22/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-part-6-poco-and-authentication-provider.aspx"&gt;this
post on Authentication in RIA Services&lt;/a&gt; before going any further. Once you have
that and can build/run it on your machine you can continue on.
&lt;/p&gt;
&lt;p&gt;
The security in Brad’s example uses a simple membership provider that is using RIA
Services FormsAuthentication since it takes a username and password to log in. For
our example we will extend the FormsAuthentication and add a timeout to it. Below
is my implementation of the FormsWithTimeoutAuthentication class:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;namespace &lt;/span&gt;MyApp { &lt;span style="color: blue"&gt;public
class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;FormsWithTimeoutAuthentication &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;FormsAuthentication &lt;/span&gt;{ &lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DispatcherTimer &lt;/span&gt;idleTimer; &lt;span style="color: blue"&gt;private
int &lt;/span&gt;minutesIdle; &lt;span style="color: blue"&gt;private bool &lt;/span&gt;idle; &lt;span style="color: blue"&gt;private
bool &lt;/span&gt;attached = &lt;span style="color: blue"&gt;false&lt;/span&gt;; &lt;span style="color: blue"&gt;public &lt;/span&gt;FormsWithTimeoutAuthentication()
: &lt;span style="color: blue"&gt;this&lt;/span&gt;(20) { } &lt;span style="color: blue"&gt;public &lt;/span&gt;FormsWithTimeoutAuthentication(&lt;span style="color: blue"&gt;int &lt;/span&gt;idleMinutes)
{ IdleMinutesBeforeTimeout = idleMinutes; idleTimer = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DispatcherTimer&lt;/span&gt;();
idleTimer.Interval = &lt;span style="color: #2b91af"&gt;TimeSpan&lt;/span&gt;.FromMinutes(1);
idleTimer.Tick += &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EventHandler&lt;/span&gt;(idleTimer_Tick);
} &lt;span style="color: blue"&gt;public int &lt;/span&gt;IdleMinutesBeforeTimeout { &lt;span style="color: blue"&gt;get&lt;/span&gt;; &lt;span style="color: blue"&gt;set&lt;/span&gt;;
} &lt;span style="color: blue"&gt;protected override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;LoginResult &lt;/span&gt;EndLogin(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;asyncResult)
{ &lt;span style="color: blue"&gt;var &lt;/span&gt;result = &lt;span style="color: blue"&gt;base&lt;/span&gt;.EndLogin(asyncResult); &lt;span style="color: blue"&gt;if &lt;/span&gt;(result.LoginSuccess
== &lt;span style="color: blue"&gt;true&lt;/span&gt;) { &lt;span style="color: blue"&gt;if &lt;/span&gt;(!attached)
AttachEvents(); minutesIdle = 0; idleTimer.Start(); } &lt;span style="color: blue"&gt;return &lt;/span&gt;result;
} &lt;span style="color: blue"&gt;protected override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;LogoutResult &lt;/span&gt;EndLogout(&lt;span style="color: #2b91af"&gt;IAsyncResult &lt;/span&gt;asyncResult)
{ idleTimer.Stop(); &lt;span style="color: blue"&gt;return base&lt;/span&gt;.EndLogout(asyncResult);
} &lt;span style="color: blue"&gt;private void &lt;/span&gt;AttachEvents() { attached = &lt;span style="color: blue"&gt;true&lt;/span&gt;; &lt;span style="color: #2b91af"&gt;Application&lt;/span&gt;.Current.RootVisual.MouseMove
+= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MouseEventHandler&lt;/span&gt;(RootVisual_MouseMove); &lt;span style="color: #2b91af"&gt;Application&lt;/span&gt;.Current.RootVisual.KeyDown
+= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;KeyEventHandler&lt;/span&gt;(RootVisual_KeyDown);
} &lt;span style="color: blue"&gt;private void &lt;/span&gt;RootVisual_KeyDown(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;KeyEventArgs &lt;/span&gt;e)
{ idle = &lt;span style="color: blue"&gt;false&lt;/span&gt;; } &lt;span style="color: blue"&gt;private
void &lt;/span&gt;RootVisual_MouseMove(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;MouseEventArgs &lt;/span&gt;e)
{ idle = &lt;span style="color: blue"&gt;false&lt;/span&gt;; } &lt;span style="color: blue"&gt;private
void &lt;/span&gt;idleTimer_Tick(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
{ &lt;span style="color: blue"&gt;if &lt;/span&gt;(idle == &lt;span style="color: blue"&gt;true&lt;/span&gt;)
{ minutesIdle += idleTimer.Interval.Minutes; &lt;span style="color: blue"&gt;if &lt;/span&gt;(minutesIdle
&amp;gt;= IdleMinutesBeforeTimeout) { Logout(); } } &lt;span style="color: blue"&gt;else &lt;/span&gt;{
minutesIdle = 0; } idle = &lt;span style="color: blue"&gt;true&lt;/span&gt;; } } }&lt;/pre&gt;
&lt;p&gt;
All this class does is add a timer that fires once a minute. If the user has either
moved the mouse or hit a key in that minute then they stay logged in. If the user
hasn’t, then a minute of idle time is added to the idle minute count until the timeout
limit is reached. Once that happens the user gets logged out. 
&lt;/p&gt;
&lt;p&gt;
Note that the events are attached to the root visual and don’t get attached until
the user logs in. This is because the Authentication is created prior to the RootVisual
being set. 
&lt;/p&gt;
&lt;p&gt;
Simply add this code to the sample project (linked above) and then change the authentication
service in the App.xaml as follows:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Application &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Class&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;MyApp.App&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;app&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;clr-namespace:MyApp&amp;quot; &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;appsvc&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;clr-namespace:System.Windows.Ria.ApplicationServices;assembly=System.Windows.Ria&amp;quot;
&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Application.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary.MergedDictionaries&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary &lt;/span&gt;&lt;span style="color: red"&gt;Source&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;Assets/Styles.xaml&amp;quot;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary.MergedDictionaries&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ResourceDictionary&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Application.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Application.ApplicationLifetimeObjects&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;app&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;RiaContext&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;app&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;RiaContext.Authentication&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; &lt;strong&gt;&amp;lt;&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style="color: #a31515"&gt;app&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;FormsWithTimeoutAuthentication &lt;/span&gt;&lt;span style="color: red"&gt;IdleMinutesBeforeTimeout&lt;/span&gt;&lt;/strong&gt;&lt;span style="color: blue"&gt;&lt;strong&gt;=&amp;quot;2&amp;quot;/&amp;gt; &lt;/strong&gt; &lt;/span&gt;&lt;span style="color: green"&gt;&amp;lt;!--&amp;lt;appsvc:WindowsAuthentication/&amp;gt;--&amp;gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;app&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;RiaContext.Authentication&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;app&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;RiaContext&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Application.ApplicationLifetimeObjects&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Application&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Here I’ve set the IdleMinutesBeforeTimeout to 2 minutes so that it is easy to test. 
&lt;/p&gt;
&lt;p&gt;
Once you’ve modified the application, when you run it you will get logged out after
the number of minutes you specify in the timeout. There are lots of enhancements that
could be made to this simple approach, but this works for most situations.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=35268791-0ffb-4708-aeb4-b3bb2d99f837" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,35268791-0ffb-4708-aeb4-b3bb2d99f837.aspx</comments>
      <category>RiaServices</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=450ba014-3672-4655-b389-ab9bcc125163</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,450ba014-3672-4655-b389-ab9bcc125163.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,450ba014-3672-4655-b389-ab9bcc125163.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=450ba014-3672-4655-b389-ab9bcc125163</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you’re reading this then you’re on my new blog homepage at <a href="http://bryantlikes.com">http://bryantlikes.com</a>.
I’ve wanted to move off of <a href="http://blogs.sqlxml.org">http://blogs.sqlxml.org</a> for
some time but every time I start to work on it I get overwhelmed by the amount of
work involved. I would usually get stuck on (1) how to migrate all my content and
(2) where to host it since there is a lot of content and most hosting providers give
you very little SQL storage. 
</p>
        <p>
I looked at a lot of options and even <a href="http://bryantlikes.cloudapp.net/">setup
Oxite on Azure</a> by following <a href="http://origin.cloudapp.net/Blog/Setup-Oxite-Site-on-Windows-Azure">this
guide</a>, but since I didn’t know what the monthly costs will be I decided not to
take that route. Since I was <a href="http://bryantlikes.com/SilverlightMVP.aspx">recently
awarded the MVP award</a> I decided to look at some of the benefits and I found that <a href="http://www.orcsweb.com/">Orcs
Web</a> offers a free hosting account to MVPs. I know Orcs has a great service so
I was excited to give that a try, but I didn’t think their SQL storage would be enough
for my blog. That is when I got the idea to give <a href="http://www.dasblog.info/">dasBlog</a> a
try. DasBlog stores all your data in xml files instead of using a SQL database. At
first that sounds like a bad idea, but if it can support <a href="http://www.hanselman.com/blog/">Hanselman’s
blog</a>, then surely my blog would have no problems at all. Plus it solves the SQL
storage issue.
</p>
        <p>
Now the harder question, how do you migrate all the content. At first I tried using
the <a href="http://blogml.codeplex.com/">BlogML</a> stuff to pull all my content
out of <a href="http://telligent.com/">Community Server</a>, but I have a lot of content
so I ended up getting lots of exceptions. I tried to hand code some solutions, but
finally gave up. Then I got the idea to just take the simple route and write a custom
program to read the data from my CS database and generate the XML files that dasBlog
uses. So I used some Linq to SQL classes and wrote the XML using Linq to XML. It was
fairly easy to do and it worked great. 
</p>
        <p>
The next step was to setup the redirects on the old site to point to the new site.
I have all the articles redirecting and I think they all work (for the most part).
I had to setup some custom redirects for some of the articles with non-standard characters
in the titles, but other than that it was pretty easy. I also followed Scott’s post
on <a href="http://www.hanselman.com/blog/UsingISAPIRewriteToCanonicalizeASPNETURLsAndRemoveDefaultaspx.aspx">canonicalize
my URLs</a> and <a href="http://www.hanselman.com/blog/ASPNETMVCAndTheNewIIS7RewriteModule.aspx">using
IIS7</a>’s rewrite module. Orcs provides access to your <a href="http://www.iis.net/extensions/IISManager">IIS7’s
manager remotely</a> which works great. 
</p>
        <p>
I still need to migrate my articles, but I’ll get those done later today. Other than
that it is a done deal. I’m very happy to be off the sqlxml.org domain which I still
host at home and to be off of Community Server. 
</p>
        <p>
Lately, I wanted to thank <a href="http://www.therightstuff.de/">Alexander Groß</a> for
the great theme which he created. I think this new blog is much easier to read and
so far I’ve enjoyed the dasBlog software. I’ve even write a custom macro to put the
RSS feeds on the category pages. I’m sure I’ll do some more customization down the
road and post about as I go.
</p>
        <p>
Hope you like the new blog!
</p>
        <img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=450ba014-3672-4655-b389-ab9bcc125163" />
      </body>
      <title>Migrated from Community Server to DasBlog</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,450ba014-3672-4655-b389-ab9bcc125163.aspx</guid>
      <link>http://bryantlikes.com/MigratedFromCommunityServerToDasBlog.aspx</link>
      <pubDate>Sat, 17 Oct 2009 15:30:18 GMT</pubDate>
      <description>&lt;p&gt;
If you’re reading this then you’re on my new blog homepage at &lt;a href="http://bryantlikes.com"&gt;http://bryantlikes.com&lt;/a&gt;.
I’ve wanted to move off of &lt;a href="http://blogs.sqlxml.org"&gt;http://blogs.sqlxml.org&lt;/a&gt; for
some time but every time I start to work on it I get overwhelmed by the amount of
work involved. I would usually get stuck on (1) how to migrate all my content and
(2) where to host it since there is a lot of content and most hosting providers give
you very little SQL storage. 
&lt;/p&gt;
&lt;p&gt;
I looked at a lot of options and even &lt;a href="http://bryantlikes.cloudapp.net/"&gt;setup
Oxite on Azure&lt;/a&gt; by following &lt;a href="http://origin.cloudapp.net/Blog/Setup-Oxite-Site-on-Windows-Azure"&gt;this
guide&lt;/a&gt;, but since I didn’t know what the monthly costs will be I decided not to
take that route. Since I was &lt;a href="http://bryantlikes.com/SilverlightMVP.aspx"&gt;recently
awarded the MVP award&lt;/a&gt; I decided to look at some of the benefits and I found that &lt;a href="http://www.orcsweb.com/"&gt;Orcs
Web&lt;/a&gt; offers a free hosting account to MVPs. I know Orcs has a great service so
I was excited to give that a try, but I didn’t think their SQL storage would be enough
for my blog. That is when I got the idea to give &lt;a href="http://www.dasblog.info/"&gt;dasBlog&lt;/a&gt; a
try. DasBlog stores all your data in xml files instead of using a SQL database. At
first that sounds like a bad idea, but if it can support &lt;a href="http://www.hanselman.com/blog/"&gt;Hanselman’s
blog&lt;/a&gt;, then surely my blog would have no problems at all. Plus it solves the SQL
storage issue.
&lt;/p&gt;
&lt;p&gt;
Now the harder question, how do you migrate all the content. At first I tried using
the &lt;a href="http://blogml.codeplex.com/"&gt;BlogML&lt;/a&gt; stuff to pull all my content
out of &lt;a href="http://telligent.com/"&gt;Community Server&lt;/a&gt;, but I have a lot of content
so I ended up getting lots of exceptions. I tried to hand code some solutions, but
finally gave up. Then I got the idea to just take the simple route and write a custom
program to read the data from my CS database and generate the XML files that dasBlog
uses. So I used some Linq to SQL classes and wrote the XML using Linq to XML. It was
fairly easy to do and it worked great. 
&lt;/p&gt;
&lt;p&gt;
The next step was to setup the redirects on the old site to point to the new site.
I have all the articles redirecting and I think they all work (for the most part).
I had to setup some custom redirects for some of the articles with non-standard characters
in the titles, but other than that it was pretty easy. I also followed Scott’s post
on &lt;a href="http://www.hanselman.com/blog/UsingISAPIRewriteToCanonicalizeASPNETURLsAndRemoveDefaultaspx.aspx"&gt;canonicalize
my URLs&lt;/a&gt; and &lt;a href="http://www.hanselman.com/blog/ASPNETMVCAndTheNewIIS7RewriteModule.aspx"&gt;using
IIS7&lt;/a&gt;’s rewrite module. Orcs provides access to your &lt;a href="http://www.iis.net/extensions/IISManager"&gt;IIS7’s
manager remotely&lt;/a&gt; which works great. 
&lt;/p&gt;
&lt;p&gt;
I still need to migrate my articles, but I’ll get those done later today. Other than
that it is a done deal. I’m very happy to be off the sqlxml.org domain which I still
host at home and to be off of Community Server. 
&lt;/p&gt;
&lt;p&gt;
Lately, I wanted to thank &lt;a href="http://www.therightstuff.de/"&gt;Alexander Groß&lt;/a&gt; for
the great theme which he created. I think this new blog is much easier to read and
so far I’ve enjoyed the dasBlog software. I’ve even write a custom macro to put the
RSS feeds on the category pages. I’m sure I’ll do some more customization down the
road and post about as I go.
&lt;/p&gt;
&lt;p&gt;
Hope you like the new blog!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=450ba014-3672-4655-b389-ab9bcc125163" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,450ba014-3672-4655-b389-ab9bcc125163.aspx</comments>
      <category>Community Server</category>
      <category>dasBlog</category>
      <category>Sql and Xml</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=d5f748dd-ffaa-4cd1-ac58-73928fc7b45b</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,d5f748dd-ffaa-4cd1-ac58-73928fc7b45b.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,d5f748dd-ffaa-4cd1-ac58-73928fc7b45b.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d5f748dd-ffaa-4cd1-ac58-73928fc7b45b</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
On October 1st I was honored to receive the <a href="https://mvp.support.microsoft.com/">Microsoft
Most Valuable Professional Award</a> for <a href="http://www.microsoft.com/silverlight">Silverlight</a>.
I am very excited that I received this award and look forward to continuing my contributions
to the <a href="http://silverlight.net/community">Silverlight Community</a>. 
</p>
        <p>
          <img src="http://files.bryantlikes.com/Images/mvp.png" />
        </p>
        <p>
I wasn’t the only one to receive this honor as <a href="http://timheuer.com/blog/archive/2009/10/01/new-silverlight-mvp-announcement-october-2009.aspx">Tim
Heuer blogged here</a>:
</p>
        <blockquote>
          <p>
As of today (01 OCT 2009) we welcome some new folks to the Silverlight group:
</p>
          <ul>
            <li>
              <a href="http://www.cynergysystems.com/blogs/blogs/rick.barraza/">Rick Barraza</a> (<a href="http://twitter.com/rickbarraza">@rickbarraza</a>)–
wicked interactive design/developer with kung-fu XAML skillz 
</li>
            <li>
              <a href="http://blogs.sqlxml.org/BryantLikes">Bryant Likes</a> (<a href="http://twitter.com/bryantlikes">@bryantlikes</a>)–
great contributor to the Silverlight Forums helping others solve their problems! 
</li>
            <li>
              <a href="http://85turns.com">Corey Schuman</a> (<a href="http://twitter.com/cschuman">@cschuman</a>)–
UX design/developer in Atlanta doing a bunch of great Silverlight community work 
</li>
            <li>
              <a href="http://www.davidezordan.net/blog/">Davide Zordan</a> (<a href="http://twitter.com/davidezordan">@davidezordan</a>)–
over the pond in Italy spreading the Silverlight love! 
</li>
            <li>
              <a href="http://www.designwithsilverlight.com/">Jeff Paries</a> – Silverlight animation
wizard – <a href="http://tinyurl.com/sl3animation">get his book</a>! 
</li>
            <li>
              <a href="http://nerdplusart.com">Robby Ingebretsen</a> (<a href="http://twitter.com/ingebretsen">@ingebretsen</a>)–
another kung-fu XAML/Blend ninja 
</li>
            <li>
Ambrose Little (<a href="http://twitter.com/AmbroseLittle">@ambroselittle</a>)– co-author
of <a href="http://tinyurl.com/sl3progref">Silverlight 3 Programmer Reference</a> and
the man behind <a href="http://quince.infragistics.com">Quince</a> (no <a href="http://twitter.com/ambrosesbeard">@ambrosesbeard</a> was
not awarded) 
</li>
            <li>
              <a href="http://www.cnblogs.com/terrylee">Huijun Li</a> – helping spread the Silverlight
in China overseas! 
</li>
          </ul>
        </blockquote>
        <p>
I’m very excited to be a part of the <a href="https://mvp.support.microsoft.com/communities/mvp.aspx?product=1&amp;competency=Silverlight">Silverlight
MVPs group</a> and look forward to working with them all.
</p>
        <img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=d5f748dd-ffaa-4cd1-ac58-73928fc7b45b" />
      </body>
      <title>Silverlight MVP</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,d5f748dd-ffaa-4cd1-ac58-73928fc7b45b.aspx</guid>
      <link>http://bryantlikes.com/SilverlightMVP.aspx</link>
      <pubDate>Fri, 16 Oct 2009 22:55:54 GMT</pubDate>
      <description>&lt;p&gt;
On October 1st I was honored to receive the &lt;a href="https://mvp.support.microsoft.com/"&gt;Microsoft
Most Valuable Professional Award&lt;/a&gt; for &lt;a href="http://www.microsoft.com/silverlight"&gt;Silverlight&lt;/a&gt;.
I am very excited that I received this award and look forward to continuing my contributions
to the &lt;a href="http://silverlight.net/community"&gt;Silverlight Community&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://files.bryantlikes.com/Images/mvp.png" /&gt;
&lt;/p&gt;
&lt;p&gt;
I wasn’t the only one to receive this honor as &lt;a href="http://timheuer.com/blog/archive/2009/10/01/new-silverlight-mvp-announcement-october-2009.aspx"&gt;Tim
Heuer blogged here&lt;/a&gt;:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
As of today (01 OCT 2009) we welcome some new folks to the Silverlight group:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.cynergysystems.com/blogs/blogs/rick.barraza/"&gt;Rick Barraza&lt;/a&gt; (&lt;a href="http://twitter.com/rickbarraza"&gt;@rickbarraza&lt;/a&gt;)–
wicked interactive design/developer with kung-fu XAML skillz 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blogs.sqlxml.org/BryantLikes"&gt;Bryant Likes&lt;/a&gt; (&lt;a href="http://twitter.com/bryantlikes"&gt;@bryantlikes&lt;/a&gt;)–
great contributor to the Silverlight Forums helping others solve their problems! 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://85turns.com"&gt;Corey Schuman&lt;/a&gt; (&lt;a href="http://twitter.com/cschuman"&gt;@cschuman&lt;/a&gt;)–
UX design/developer in Atlanta doing a bunch of great Silverlight community work 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.davidezordan.net/blog/"&gt;Davide Zordan&lt;/a&gt; (&lt;a href="http://twitter.com/davidezordan"&gt;@davidezordan&lt;/a&gt;)–
over the pond in Italy spreading the Silverlight love! 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.designwithsilverlight.com/"&gt;Jeff Paries&lt;/a&gt; – Silverlight animation
wizard – &lt;a href="http://tinyurl.com/sl3animation"&gt;get his book&lt;/a&gt;! 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://nerdplusart.com"&gt;Robby Ingebretsen&lt;/a&gt; (&lt;a href="http://twitter.com/ingebretsen"&gt;@ingebretsen&lt;/a&gt;)–
another kung-fu XAML/Blend ninja 
&lt;/li&gt;
&lt;li&gt;
Ambrose Little (&lt;a href="http://twitter.com/AmbroseLittle"&gt;@ambroselittle&lt;/a&gt;)– co-author
of &lt;a href="http://tinyurl.com/sl3progref"&gt;Silverlight 3 Programmer Reference&lt;/a&gt; and
the man behind &lt;a href="http://quince.infragistics.com"&gt;Quince&lt;/a&gt; (no &lt;a href="http://twitter.com/ambrosesbeard"&gt;@ambrosesbeard&lt;/a&gt; was
not awarded) 
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.cnblogs.com/terrylee"&gt;Huijun Li&lt;/a&gt; – helping spread the Silverlight
in China overseas! 
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I’m very excited to be a part of the &lt;a href="https://mvp.support.microsoft.com/communities/mvp.aspx?product=1&amp;amp;competency=Silverlight"&gt;Silverlight
MVPs group&lt;/a&gt; and look forward to working with them all.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=d5f748dd-ffaa-4cd1-ac58-73928fc7b45b" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,d5f748dd-ffaa-4cd1-ac58-73928fc7b45b.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=dc46ed9e-11d7-4a23-a51a-d897efaad9f6</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,dc46ed9e-11d7-4a23-a51a-d897efaad9f6.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,dc46ed9e-11d7-4a23-a51a-d897efaad9f6.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=dc46ed9e-11d7-4a23-a51a-d897efaad9f6</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
As a Silverlight developer, when you want to add functionality to an existing control,
you have two main options as I see it (if you want to get reuse from your code). You
can either subclass the control or, as of Silverlight 3,  you can write a behavior
for it. For example, one of the requests for the current Silverlight application that
I’ve been working on was to have the TextBox select all the text when you tabbed to
it or clicked in it. We can easily add this functionality using both of the above
methods:
</p>
        <p>
Here is how this could be done using subclassing:
</p>
        <pre class="csharpcode">
          <span class="kwrd">public</span>
          <span class="kwrd">class</span> SelectAllTextBox
: TextBox { <span class="kwrd">public</span> SelectAllTextBox() { <span class="kwrd">this</span>.GotFocus
+= <span class="kwrd">new</span> RoutedEventHandler(TextBox_GotFocus); } <span class="kwrd">private</span><span class="kwrd">void</span> TextBox_GotFocus(<span class="kwrd">object</span> sender,
RoutedEventArgs e) { <span class="kwrd">this</span>.SelectAll(); } }</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>
And here is how you would write this as a behavior:
</p>
        <pre class="csharpcode">
          <span class="kwrd">public</span>
          <span class="kwrd">class</span> SelectAllBehavior
: Behavior&lt;TextBox&gt; { <span class="kwrd">protected</span><span class="kwrd">override</span><span class="kwrd">void</span> OnAttached()
{ <span class="kwrd">base</span>.OnAttached(); AssociatedObject.GotFocus += <span class="kwrd">new</span> RoutedEventHandler(AssociatedObject_GotFocus);
} <span class="kwrd">void</span> AssociatedObject_GotFocus(<span class="kwrd">object</span> sender,
RoutedEventArgs e) { ((TextBox)sender).SelectAll(); } }</pre>
        <p>
The behavior has one more line of code and the added requirement of adding a reference
to System.Windows.Interactivity.dll from the Blend 3 SDK. The bigger difference is
how the code looks in our view when we add the control to it. 
</p>
        <p>
The subclassed control looks like (where ctrls is the controls namespace of our subclassed
control):
</p>
        <pre class="code">
          <span style="color: blue">&lt;</span>
          <span style="color: #a31515">ctrls</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">SelectAllTextBox </span>
          <span style="color: red">Text</span>
          <span style="color: blue">="{</span>
          <span style="color: #a31515">Binding </span>
          <span style="color: red">MyText</span>
          <span style="color: blue">}"
/</span>
          <span style="color: blue">&gt;</span>
        </pre>
        <p>
          <a href="http://11011.net/software/vspaste">
          </a>And the behavior looks like (where
i is the System.Windows.Interactivity namespace and b is our behavior’s namespace):
</p>
        <pre class="code">
          <span style="color: blue">&lt;</span>
          <span style="color: #a31515">TextBox </span>
          <span style="color: red">Text</span>
          <span style="color: blue">="{</span>
          <span style="color: #a31515">Binding </span>
          <span style="color: red">MyText</span>
          <span style="color: blue">}"</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">i</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">Interaction.Behaviors</span>
          <span style="color: blue">&gt;
&lt;</span>
          <span style="color: #a31515">b</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">SelectAllBehavior </span>
          <span style="color: blue">/&gt;
&lt;/</span>
          <span style="color: #a31515">i</span>
          <span style="color: blue">:</span>
          <span style="color: #a31515">Interaction.Behaviors</span>
          <span style="color: blue">&gt;
&lt;/</span>
          <span style="color: #a31515">TextBox</span>
          <span style="color: blue">&gt;</span>
        </pre>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
Obviously the behavior is more verbose in this case than the subclassed approach.
</p>
        <p>
Since both of these approaches work, which is the better approach? I think the subclassing
is the easier approach, but I think the behavior would be the recommended approach.
The reason is that I can build my SelectAll behavior today and then down the road
build a different behavior and then selectively apply them to my TextBoxes as appropriate.
However, if use the subclass approach I would automatically get the new behavior on
all my controls which might not be what I wanted. It also means that if someone builds
a better TextBox that I want to use that I would have to try to subclass that control,
but with the behavior I could just apply it to the new control. 
</p>
        <p>
          <strong>Update: </strong>A couple of quick updates. First, <a href="http://twitter.com/a7an/status/4501862233">Alan
Le pointed out</a> that it depends on reuse. Obviously if you had to add the behavior
to 20 TextBoxes it would take more time to use the behavior. However, Blend makes
this a lot easier. Secondly, Brian mentioned in the comments that you could also use
an attached property to do this so I thought I would quickly show what that might
look like.
</p>
        <p>
The code for the attached property would be:
</p>
        <pre class="csharpcode">
          <span class="kwrd">public</span>
          <span class="kwrd">static</span>
          <span class="kwrd">class</span> TextBoxProperties
{ <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">readonly</span> DependencyProperty
SelectAllProperty = DependencyProperty.RegisterAttached(<span class="str">"SelectAll"</span>, <span class="kwrd">typeof</span>(<span class="kwrd">bool</span>), <span class="kwrd">typeof</span>(TextBoxProperties), <span class="kwrd">new</span> PropertyMetadata(<span class="kwrd">false</span>,
OnSelectAllChanged)); <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">void</span> SetSelectAll(DependencyObject
o, <span class="kwrd">bool</span><span class="kwrd">value</span>) { o.SetValue(SelectAllProperty, <span class="kwrd">value</span>);
} <span class="kwrd">public</span><span class="kwrd">static</span><span class="kwrd">bool</span> GetSelectAll(DependencyObject
o) { <span class="kwrd">return</span> (<span class="kwrd">bool</span>)o.GetValue(SelectAllProperty);
} <span class="kwrd">private</span><span class="kwrd">static</span><span class="kwrd">void</span> OnSelectAllChanged(DependencyObject
d, DependencyPropertyChangedEventArgs e) { <span class="kwrd">if</span> ((<span class="kwrd">bool</span>)e.NewValue
== <span class="kwrd">true</span>) { ((TextBox)d).GotFocus += <span class="kwrd">new</span> RoutedEventHandler(TextBoxProperties_GotFocus);
} } <span class="kwrd">private</span><span class="kwrd">static</span><span class="kwrd">void</span> TextBoxProperties_GotFocus(<span class="kwrd">object</span> sender,
RoutedEventArgs e) { ((TextBox)sender).SelectAll(); } }</pre>
        <p>
And the Xaml would look like:
</p>
        <pre class="csharpcode">
          <span style="color: blue">&lt;</span>
          <span style="color: #a31515">TextBox </span>
          <span style="color: red">Text</span>
          <span style="color: blue">="{</span>
          <span style="color: #a31515">Binding </span>
          <span style="color: red">MyText</span>
          <span style="color: blue">}"
ctrls:TextBoxProperties.SelectAll=<span style="color: blue">"true</span><span style="color: blue">"
/</span></span>
          <span style="color: blue">&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>
I still think the Behavior is the best method to use since (at least in this case)
we are just trying to add a behavior to the TextBox, not add significant functionality.
The attached property also doesn’t feel right to me, but it does work just fine. Ultimately
it comes down to preference and what method you like to use. :)
</p>
        <img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=dc46ed9e-11d7-4a23-a51a-d897efaad9f6" />
      </body>
      <title>Behaviors vs Subclassing in Silverlight</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,dc46ed9e-11d7-4a23-a51a-d897efaad9f6.aspx</guid>
      <link>http://bryantlikes.com/BehaviorsVsSubclassingInSilverlight.aspx</link>
      <pubDate>Wed, 30 Sep 2009 08:42:54 GMT</pubDate>
      <description>&lt;p&gt;
As a Silverlight developer, when you want to add functionality to an existing control,
you have two main options as I see it (if you want to get reuse from your code). You
can either subclass the control or, as of Silverlight 3,&amp;#160; you can write a behavior
for it. For example, one of the requests for the current Silverlight application that
I’ve been working on was to have the TextBox select all the text when you tabbed to
it or clicked in it. We can easily add this functionality using both of the above
methods:
&lt;/p&gt;
&lt;p&gt;
Here is how this could be done using subclassing:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SelectAllTextBox
: TextBox { &lt;span class="kwrd"&gt;public&lt;/span&gt; SelectAllTextBox() { &lt;span class="kwrd"&gt;this&lt;/span&gt;.GotFocus
+= &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(TextBox_GotFocus); } &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TextBox_GotFocus(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
RoutedEventArgs e) { &lt;span class="kwrd"&gt;this&lt;/span&gt;.SelectAll(); } }&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;
And here is how you would write this as a behavior:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SelectAllBehavior
: Behavior&amp;lt;TextBox&amp;gt; { &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnAttached()
{ &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnAttached(); AssociatedObject.GotFocus += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(AssociatedObject_GotFocus);
} &lt;span class="kwrd"&gt;void&lt;/span&gt; AssociatedObject_GotFocus(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
RoutedEventArgs e) { ((TextBox)sender).SelectAll(); } }&lt;/pre&gt;
&lt;p&gt;
The behavior has one more line of code and the added requirement of adding a reference
to System.Windows.Interactivity.dll from the Blend 3 SDK. The bigger difference is
how the code looks in our view when we add the control to it. 
&lt;/p&gt;
&lt;p&gt;
The subclassed control looks like (where ctrls is the controls namespace of our subclassed
control):
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ctrls&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;SelectAllTextBox &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;MyText&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;
/&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;And the behavior looks like (where
i is the System.Windows.Interactivity namespace and b is our behavior’s namespace):
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;MyText&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;i&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Interaction.Behaviors&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;b&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;SelectAllBehavior &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;i&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;Interaction.Behaviors&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
Obviously the behavior is more verbose in this case than the subclassed approach.
&lt;/p&gt;
&lt;p&gt;
Since both of these approaches work, which is the better approach? I think the subclassing
is the easier approach, but I think the behavior would be the recommended approach.
The reason is that I can build my SelectAll behavior today and then down the road
build a different behavior and then selectively apply them to my TextBoxes as appropriate.
However, if use the subclass approach I would automatically get the new behavior on
all my controls which might not be what I wanted. It also means that if someone builds
a better TextBox that I want to use that I would have to try to subclass that control,
but with the behavior I could just apply it to the new control. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Update: &lt;/strong&gt;A couple of quick updates. First, &lt;a href="http://twitter.com/a7an/status/4501862233"&gt;Alan
Le pointed out&lt;/a&gt; that it depends on reuse. Obviously if you had to add the behavior
to 20 TextBoxes it would take more time to use the behavior. However, Blend makes
this a lot easier. Secondly, Brian mentioned in the comments that you could also use
an attached property to do this so I thought I would quickly show what that might
look like.
&lt;/p&gt;
&lt;p&gt;
The code for the attached property would be:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; TextBoxProperties
{ &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
SelectAllProperty = DependencyProperty.RegisterAttached(&lt;span class="str"&gt;&amp;quot;SelectAll&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;bool&lt;/span&gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(TextBoxProperties), &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyMetadata(&lt;span class="kwrd"&gt;false&lt;/span&gt;,
OnSelectAllChanged)); &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SetSelectAll(DependencyObject
o, &lt;span class="kwrd"&gt;bool&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;) { o.SetValue(SelectAllProperty, &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;bool&lt;/span&gt; GetSelectAll(DependencyObject
o) { &lt;span class="kwrd"&gt;return&lt;/span&gt; (&lt;span class="kwrd"&gt;bool&lt;/span&gt;)o.GetValue(SelectAllProperty);
} &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnSelectAllChanged(DependencyObject
d, DependencyPropertyChangedEventArgs e) { &lt;span class="kwrd"&gt;if&lt;/span&gt; ((&lt;span class="kwrd"&gt;bool&lt;/span&gt;)e.NewValue
== &lt;span class="kwrd"&gt;true&lt;/span&gt;) { ((TextBox)d).GotFocus += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(TextBoxProperties_GotFocus);
} } &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TextBoxProperties_GotFocus(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
RoutedEventArgs e) { ((TextBox)sender).SelectAll(); } }&lt;/pre&gt;
&lt;p&gt;
And the Xaml would look like:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;MyText&lt;/span&gt;&lt;span style="color: blue"&gt;}&amp;quot;
ctrls:TextBoxProperties.SelectAll=&lt;span style="color: blue"&gt;&amp;quot;true&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;quot;
/&lt;/span&gt;&lt;/span&gt;&lt;span style="color: blue"&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;
I still think the Behavior is the best method to use since (at least in this case)
we are just trying to add a behavior to the TextBox, not add significant functionality.
The attached property also doesn’t feel right to me, but it does work just fine. Ultimately
it comes down to preference and what method you like to use. :)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=dc46ed9e-11d7-4a23-a51a-d897efaad9f6" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,dc46ed9e-11d7-4a23-a51a-d897efaad9f6.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=9acdfc9f-b109-469a-a209-1cf9f6084479</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,9acdfc9f-b109-469a-a209-1cf9f6084479.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,9acdfc9f-b109-469a-a209-1cf9f6084479.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9acdfc9f-b109-469a-a209-1cf9f6084479</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>A “Default Command” for Silverlight</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,9acdfc9f-b109-469a-a209-1cf9f6084479.aspx</guid>
      <link>http://bryantlikes.com/ADefaultCommandForSilverlight.aspx</link>
      <pubDate>Mon, 28 Sep 2009 14:23:00 GMT</pubDate>
      <description>&lt;p&gt;
The current Silverlight application that I&amp;rsquo;m building has a Login view. One
of the things that bugged me when I started using the application is that you would
have to click the Login button after typing your password. I wanted to duplicate the
default button behavior of HTML forms where when you hit the enter key it would trigger
the default button on the form. I did some googling on the subject and came across &lt;a href="http://www.cauldwell.net/patrick/blog/ALdquodefaultButtonrdquoInSilverlight.aspx"&gt;this
post by Patrick Cauldwell&lt;/a&gt; which is one way to solve the problem. However, in my
case I had a username Textbox, a password Passwordbox, and a company Combobox and
didn&amp;rsquo;t want to specify the button for each control. 
&lt;/p&gt;
&lt;p&gt;
So I create a simple solution of creating a content control that attaches to all the
KeyUp events of all the child FrameworkElements in the content. To do this I used
the FindChildren&amp;lt;T&amp;gt; extension method from the &lt;a href="http://www.avanade.com"&gt;Avanade
Silverlight Accelerator&lt;/a&gt; which is a toolkit we use internally at Avanade to speed
up Silverlight development. The ContentControl exposes a DefaultCommand property which
you then bind to the ICommand property on your ViewModel. 
&lt;/p&gt;
&lt;p&gt;
Below is a trimmed down example of the Login view. I&amp;rsquo;m using a variant of the
RelayCommand/DelegateCommand as the LoginCommand here (see &lt;a href="http://blog.galasoft.ch/archive/2009/09/26/using-relaycommands-in-silverlight-and-wpf.aspx"&gt;Laurent&amp;rsquo;s
post on the RelayCommand&lt;/a&gt; for a good overview of Commands in Silverlight). 
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ctrls&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;FormControl &lt;/span&gt;&lt;span style="color: red"&gt;DefaultCommand&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;LoginCommand&lt;/span&gt;&lt;span style="color: blue"&gt;}"&amp;gt;&lt;/span&gt;&lt;span style="color: blue"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TextBox &lt;/span&gt;&lt;span style="color: red"&gt;Text&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;Username&lt;/span&gt;&lt;span style="color: blue"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;Mode&lt;/span&gt;&lt;span style="color: blue"&gt;=TwoWay}" &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;PasswordBox &lt;/span&gt;&lt;span style="color: red"&gt;Password&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;Password&lt;/span&gt;&lt;span style="color: blue"&gt;, &lt;/span&gt;&lt;span style="color: red"&gt;Mode&lt;/span&gt;&lt;span style="color: blue"&gt;=TwoWay}" &lt;/span&gt;&lt;span style="color: blue"&gt;/&amp;gt; &lt;/span&gt;&lt;span style="color: blue"&gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Button &lt;/span&gt;&lt;span style="color: red"&gt;IsEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;LoginEnabled&lt;/span&gt;&lt;span style="color: blue"&gt;}" &lt;/span&gt;&lt;span style="color: red"&gt;cmds&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;ButtonClickCommand.Command&lt;/span&gt;&lt;span style="color: blue"&gt;="{&lt;/span&gt;&lt;span style="color: #a31515"&gt;Binding &lt;/span&gt;&lt;span style="color: red"&gt;LoginCommand&lt;/span&gt;&lt;span style="color: blue"&gt;}" &lt;/span&gt;&lt;span style="color: red"&gt;Content&lt;/span&gt;&lt;span style="color: blue"&gt;="Login"
/&amp;gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ctrls&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: #a31515"&gt;FormControl&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;There are many other things you could
add to this but this is all the functionality that I needed and I decided to keep
it simple. Download the class file (plus the extension method) below. Let me know
if you find it useful!
&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:8bbfa932-331f-42e7-9bad-0990c0879062" style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px"&gt;
&lt;div&gt;&lt;a target="_self" href="http://files.bryantlikes.com/Code/FormControl.cs"&gt;FormControl.cs&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=9acdfc9f-b109-469a-a209-1cf9f6084479" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,9acdfc9f-b109-469a-a209-1cf9f6084479.aspx</comments>
      <category>Avanade</category>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=2bb1e37c-9309-4bf3-9197-0192df020e78</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,2bb1e37c-9309-4bf3-9197-0192df020e78.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,2bb1e37c-9309-4bf3-9197-0192df020e78.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2bb1e37c-9309-4bf3-9197-0192df020e78</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>Faking the Initialized Event in Silverlight</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,2bb1e37c-9309-4bf3-9197-0192df020e78.aspx</guid>
      <link>http://bryantlikes.com/FakingTheInitializedEventInSilverlight.aspx</link>
      <pubDate>Tue, 24 Mar 2009 17:24:00 GMT</pubDate>
      <description>&lt;p&gt;
This is another nugget of gold gleaned from the &lt;a href="http://videos.visitmix.com/MIX09/06W"&gt;Climbing
Mt Avalon workshop&lt;/a&gt;, although I believe this one came from &lt;a href="http://twitter.com/JonathanRuss"&gt;Jonathan
Russ&lt;/a&gt;. He was talking about a bunch of threading tricks in WPF and showed how if
you wanted to run some code after everything was initialized you could use the BeginInvoke
method of the Dispatcher object. Since there are many places in my code where I want
to execute something when the control loads, but only once (since the loaded event
gets fired whenever the object gets re-added to the visual tree) I end up writing
a lot of code like:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&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; Page
: UserControl { &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; initialized
= &lt;span class="kwrd"&gt;false&lt;/span&gt;; &lt;span class="kwrd"&gt;public&lt;/span&gt; Page() { InitializeComponent();
Loaded += &lt;span class="kwrd"&gt;new&lt;/span&gt; RoutedEventHandler(Page_Loaded); } &lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Loaded(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender,
RoutedEventArgs e) { &lt;span class="kwrd"&gt;if&lt;/span&gt; (!initialized) { &lt;span class="rem"&gt;//
do some initialization work&lt;/span&gt; initialized = &lt;span class="kwrd"&gt;true&lt;/span&gt;; }
} }&lt;style type="text/css"&gt;&lt;!--mce:0--&gt;&lt;/style&gt;
&lt;/pre&gt;
&lt;p&gt;
This works, but it isn&amp;rsquo;t perfect and there seems to be a lot of issues with
the &lt;a href="http://blogs.msdn.com/silverlight_sdk/archive/2008/10/24/loaded-event-timing-in-silverlight.aspx"&gt;timing&lt;/a&gt; &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.loaded(VS.95).aspx"&gt;of&lt;/a&gt; &lt;a href="http://silverlight.net/forums/p/40306/115105.aspx#115105"&gt;the&lt;/a&gt; &lt;a href="http://blogs.msdn.com/devdave/archive/2008/10/11/control-lifecycle.aspx"&gt;loaded
event&lt;/a&gt;. So based on what Jonathan was saying, you could instead just put a call
into BeginInvoke in the contructor like so:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;&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; Page
: UserControl { &lt;span class="kwrd"&gt;public&lt;/span&gt; Page() { InitializeComponent(); Dispatcher.BeginInvoke(Initialized);
} &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Initialized() { &lt;span class="rem"&gt;//
do some initialization work&lt;/span&gt; } }&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;&lt;!--
.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; }
--&gt;&lt;/style&gt;
So what is this actually doing? BeginInvoke puts a message in the message pump that
is running under the covers of everything (note: I&amp;rsquo;m not a C++ programming so
I don&amp;rsquo;t really fully understand &lt;a href="http://en.wikipedia.org/wiki/Event_loop"&gt;message
pumps&lt;/a&gt; so this is an over simplification). Because it is last in line in the queue
of messages to process, it gets executed after all the other initialization code which
has already lined up. If you debug this you will see it actually gets called after
the Loaded event gets called. However, this code is the first thing to execute once
everything has been loaded and setup which is usually when I want my code to execute. 
&lt;/p&gt;
&lt;p&gt;
So this is a much better way to handle initialization code since you aren&amp;rsquo;t
adding event handlers that really only need to fire once and it executes once everything
is fully initialized.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=2bb1e37c-9309-4bf3-9197-0192df020e78" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,2bb1e37c-9309-4bf3-9197-0192df020e78.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=29536d88-c96c-416b-a0a8-9744f7429212</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,29536d88-c96c-416b-a0a8-9744f7429212.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,29536d88-c96c-416b-a0a8-9744f7429212.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=29536d88-c96c-416b-a0a8-9744f7429212</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>Animation Hack Using Attached Properties in Silverlight</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,29536d88-c96c-416b-a0a8-9744f7429212.aspx</guid>
      <link>http://bryantlikes.com/AnimationHackUsingAttachedPropertiesInSilverlight.aspx</link>
      <pubDate>Mon, 23 Mar 2009 15:27:00 GMT</pubDate>
      <description>&lt;p&gt;
In &lt;a href="/bryantlikes/archive/2009/03/18/styling-hack-using-attached-properties-in-silverlight.aspx"&gt;my
last post I blogged about using Attached Properties&lt;/a&gt; to get around the limitation
that only Dependency Properties can be animated. One astute commented noted that he
was guessing this could be applied to animations as well and the answer is yet it
can. However, it requires one extra step that makes it a little less appealing. 
&lt;/p&gt;
&lt;p&gt;
Also I mentioned in my last post, I got this idea from the Climbing Mt Avalon workshop
at MIX which has &lt;a href="http://videos.visitmix.com/MIX09/06W"&gt;now been posted online&lt;/a&gt; and
I would recommend watching if you&amp;rsquo;re doing Silverlight or WPF work. And now
on to the code&amp;hellip;
&lt;/p&gt;
&lt;p&gt;
Typically if you want to animating something like the width of a grid in a column
that isn&amp;rsquo;t animatable either because it isn&amp;rsquo;t a double, color, or another
easily animatable type, then you would declare a dependency property on your own host
class, usually a UserControl, and then animate that instead. A &lt;a href="http://programmerpayback.com/2008/11/08/animate-collapsing-a-grid-column-or-row-in-silverlight/"&gt;good
example is this blog post&lt;/a&gt; on the subject which is what I&amp;rsquo;ve referred to
many times. 
&lt;/p&gt;
&lt;p&gt;
However, if we take the attached property route instead of putting the code in our
user control, we could declare our own attached property to do the work for us. Here
is a simple example:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public static class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Attachments &lt;/span&gt;{ &lt;span style="color: blue"&gt;public
static readonly &lt;/span&gt;&lt;span style="color: #2b91af"&gt;DependencyProperty &lt;/span&gt;ColumnWidthProperty
= &lt;span style="color: #2b91af"&gt;DependencyProperty&lt;/span&gt;.RegisterAttached(&lt;span style="color: #a31515"&gt;"ColumnWidth"&lt;/span&gt;, &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: blue"&gt;double&lt;/span&gt;), &lt;span style="color: blue"&gt;typeof&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Attachments&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyMetadata&lt;/span&gt;( &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyChangedCallback&lt;/span&gt;(OnColumnWidthChanged))); &lt;span style="color: blue"&gt;public
static void &lt;/span&gt;SetColumnWidth(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;o, &lt;span style="color: blue"&gt;double &lt;/span&gt;value)
{ o.SetValue(ColumnWidthProperty, value); } &lt;span style="color: blue"&gt;public static
double &lt;/span&gt;GetColumnWidth(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;o)
{ &lt;span style="color: blue"&gt;return &lt;/span&gt;(&lt;span style="color: blue"&gt;double&lt;/span&gt;)o.GetValue(ColumnWidthProperty);
} &lt;span style="color: blue"&gt;private static void &lt;/span&gt;OnColumnWidthChanged(&lt;span style="color: #2b91af"&gt;DependencyObject &lt;/span&gt;d, &lt;span style="color: #2b91af"&gt;DependencyPropertyChangedEventArgs &lt;/span&gt;e)
{ ((&lt;span style="color: #2b91af"&gt;ColumnDefinition&lt;/span&gt;)d).Width = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;GridLength&lt;/span&gt;((&lt;span style="color: blue"&gt;double&lt;/span&gt;)e.NewValue);
} }&lt;/pre&gt;
&lt;p&gt;
Once we have this code we can now simply animate the attached property like so:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Class&lt;/span&gt;&lt;span style="color: blue"&gt;="SilverlightApplication1.MainPage" &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation" &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml" &lt;/span&gt;&lt;span style="color: red"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;local&lt;/span&gt;&lt;span style="color: blue"&gt;="clr-namespace:SilverlightApplication1" &lt;/span&gt;&lt;span style="color: red"&gt;Width&lt;/span&gt;&lt;span style="color: blue"&gt;="400" &lt;/span&gt;&lt;span style="color: red"&gt;Height&lt;/span&gt;&lt;span style="color: blue"&gt;="300"&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="LayoutRoot" &lt;/span&gt;&lt;span style="color: red"&gt;Background&lt;/span&gt;&lt;span style="color: blue"&gt;="White"&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Storyboard &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="expandBlue"&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DoubleAnimation &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;="blue" &lt;/span&gt;&lt;span style="color: red"&gt;To&lt;/span&gt;&lt;span style="color: blue"&gt;="300" &lt;/span&gt;&lt;span style="color: red"&gt;Duration&lt;/span&gt;&lt;span style="color: blue"&gt;="0:0:1"
/&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DoubleAnimation &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;="red" &lt;/span&gt;&lt;span style="color: red"&gt;To&lt;/span&gt;&lt;span style="color: blue"&gt;="100" &lt;/span&gt;&lt;span style="color: red"&gt;Duration&lt;/span&gt;&lt;span style="color: blue"&gt;="0:0:1"
/&amp;gt; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Storyboard&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Storyboard &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="expandRed"&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DoubleAnimation &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;="red" &lt;/span&gt;&lt;span style="color: red"&gt;To&lt;/span&gt;&lt;span style="color: blue"&gt;="300" &lt;/span&gt;&lt;span style="color: red"&gt;Duration&lt;/span&gt;&lt;span style="color: blue"&gt;="0:0:1"
/&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;DoubleAnimation &lt;/span&gt;&lt;span style="color: red"&gt;Storyboard.TargetName&lt;/span&gt;&lt;span style="color: blue"&gt;="blue" &lt;/span&gt;&lt;span style="color: red"&gt;To&lt;/span&gt;&lt;span style="color: blue"&gt;="100" &lt;/span&gt;&lt;span style="color: red"&gt;Duration&lt;/span&gt;&lt;span style="color: blue"&gt;="0:0:1"
/&amp;gt; &amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Storyboard&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.Resources&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ColumnDefinition &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="blue" &lt;/span&gt;&lt;span style="color: red"&gt;local&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Attachments.ColumnWidth&lt;/span&gt;&lt;span style="color: blue"&gt;="200"
/&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ColumnDefinition &lt;/span&gt;&lt;span style="color: red"&gt;x&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Name&lt;/span&gt;&lt;span style="color: blue"&gt;="red" &lt;/span&gt;&lt;span style="color: red"&gt;local&lt;/span&gt;&lt;span style="color: blue"&gt;:&lt;/span&gt;&lt;span style="color: red"&gt;Attachments.ColumnWidth&lt;/span&gt;&lt;span style="color: blue"&gt;="200"/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: blue"&gt;="0" &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="Blue" &lt;/span&gt;&lt;span style="color: red"&gt;MouseLeftButtonDown&lt;/span&gt;&lt;span style="color: blue"&gt;="Blue_MouseLeftButtonDown"
/&amp;gt; &amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Rectangle &lt;/span&gt;&lt;span style="color: red"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: blue"&gt;="1" &lt;/span&gt;&lt;span style="color: red"&gt;Fill&lt;/span&gt;&lt;span style="color: blue"&gt;="Red" &lt;/span&gt;&lt;span style="color: red"&gt;MouseLeftButtonDown&lt;/span&gt;&lt;span style="color: blue"&gt;="Red_MouseLeftButtonDown"/&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Grid&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UserControl&lt;/span&gt;&lt;span style="color: blue"&gt;&amp;gt; &lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;
Unfortunately if you try the above code (after adding in the mouse event handlers)
it won&amp;rsquo;t work. Why not? Well there seems to be an issue with animating custom
attached properties when setting the target property directly in code (actually you&amp;rsquo;ll
notice I left that out above. However, there is a way around it which I found over
on &lt;a href="http://blogs.msdn.com/edmaia/archive/2008/10/16/animating-custom-attached-properties-in-sl2.aspx"&gt;Ed&amp;rsquo;s
blog which is to set the target property in code&lt;/a&gt;. So here is the code behind with
the work around:
&lt;/p&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public partial class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MainPage &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;UserControl &lt;/span&gt;{ &lt;span style="color: blue"&gt;public &lt;/span&gt;MainPage()
{ InitializeComponent(); &lt;span style="color: #2b91af"&gt;Storyboard&lt;/span&gt;.SetTargetProperty(expandBlue.Children[0], &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyPath&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Attachments&lt;/span&gt;.ColumnWidthProperty)); &lt;span style="color: #2b91af"&gt;Storyboard&lt;/span&gt;.SetTargetProperty(expandBlue.Children[1], &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyPath&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Attachments&lt;/span&gt;.ColumnWidthProperty)); &lt;span style="color: #2b91af"&gt;Storyboard&lt;/span&gt;.SetTargetProperty(expandRed.Children[0], &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyPath&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Attachments&lt;/span&gt;.ColumnWidthProperty)); &lt;span style="color: #2b91af"&gt;Storyboard&lt;/span&gt;.SetTargetProperty(expandRed.Children[1], &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;PropertyPath&lt;/span&gt;(&lt;span style="color: #2b91af"&gt;Attachments&lt;/span&gt;.ColumnWidthProperty));
} &lt;span style="color: blue"&gt;private void &lt;/span&gt;Blue_MouseLeftButtonDown(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;MouseButtonEventArgs &lt;/span&gt;e)
{ expandBlue.Begin(); } &lt;span style="color: blue"&gt;private void &lt;/span&gt;Red_MouseLeftButtonDown(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;MouseButtonEventArgs &lt;/span&gt;e)
{ expandRed.Begin(); } }&lt;/pre&gt;
&lt;p&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;Once we set the target property via
code, then everything works great. However, that is a pain and makes things a lot
less clean. But still I think this is a useful approach to animating the properties
that are not easily animatable.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=29536d88-c96c-416b-a0a8-9744f7429212" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,29536d88-c96c-416b-a0a8-9744f7429212.aspx</comments>
      <category>Silverlight</category>
      <category>UX</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=e34590d7-c194-4b37-affa-f0b6034d6ea8</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,e34590d7-c194-4b37-affa-f0b6034d6ea8.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,e34590d7-c194-4b37-affa-f0b6034d6ea8.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e34590d7-c194-4b37-affa-f0b6034d6ea8</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>Styling Hack Using Attached Properties in Silverlight</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,e34590d7-c194-4b37-affa-f0b6034d6ea8.aspx</guid>
      <link>http://bryantlikes.com/StylingHackUsingAttachedPropertiesInSilverlight.aspx</link>
      <pubDate>Wed, 18 Mar 2009 17:08:00 GMT</pubDate>
      <description>&lt;p&gt;
I need to find the forum post where this question was asked, but I&amp;rsquo;ll have to
do that later since I&amp;rsquo;m at MIX09 and searching the forums is low on my list.
But I wanted to share a cool hack that I came across in the &lt;a href="http://live.visitmix.com/Agenda/Workshops.aspx#hiking-mt-avalon"&gt;Climbing
Mt Avalon&lt;/a&gt; (it was definitely a climb, not a hike).&amp;nbsp; One of the many cool
things that was shared was a tidbit by &lt;a href="http://blogs.msdn.com/jaimer/"&gt;Jaime
Rodriguez&lt;/a&gt; about using Attached Properties. 
&lt;/p&gt;
&lt;p&gt;
The question in the forums was how you can style the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.verticalscrollbarvisibility(vs.95).aspx"&gt;VerticalScrollBarVisibility&lt;/a&gt; property
on a TextBox. The problem is that since this property isn&amp;rsquo;t a &lt;a href="http://msdn.microsoft.com/en-us/library/cc221408(VS.95).aspx"&gt;DependencyProperty&lt;/a&gt;&amp;nbsp;
so it can&amp;rsquo;t be styled. You can test this out by trying the following Xaml:
&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum1" style="color: #606060"&gt; 1:&lt;/span&gt; &amp;lt;UserControl
x:Class=&lt;span style="color: #006080"&gt;"Attachment.Page"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum2" style="color: #606060"&gt; 2:&lt;/span&gt; xmlns=&lt;span style="color: #006080"&gt;"http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum3" style="color: #606060"&gt; 3:&lt;/span&gt; xmlns:x=&lt;span style="color: #006080"&gt;"http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum4" style="color: #606060"&gt; 4:&lt;/span&gt; Width=&lt;span style="color: #006080"&gt;"400"&lt;/span&gt; Height=&lt;span style="color: #006080"&gt;"300"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum5" style="color: #606060"&gt; 5:&lt;/span&gt; &amp;lt;UserControl.Resources&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum6" style="color: #606060"&gt; 6:&lt;/span&gt; &amp;lt;Style
TargetType=&lt;span style="color: #006080"&gt;"TextBox"&lt;/span&gt; x:Key=&lt;span style="color: #006080"&gt;"test"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum7" style="color: #606060"&gt; 7:&lt;/span&gt; &amp;lt;Setter
Property=&lt;span style="color: #006080"&gt;"FontSize"&lt;/span&gt; Value=&lt;span style="color: #006080"&gt;"24"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum8" style="color: #606060"&gt; 8:&lt;/span&gt; &amp;lt;Setter
Property=&lt;span style="color: #006080"&gt;"VerticalScrollBarVisibility"&lt;/span&gt; Value=&lt;span style="color: #006080"&gt;"Visible"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum9" style="color: #606060"&gt; 9:&lt;/span&gt; &amp;lt;/Style&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum10" style="color: #606060"&gt; 10:&lt;/span&gt; &amp;lt;/UserControl.Resources&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum11" style="color: #606060"&gt; 11:&lt;/span&gt; &amp;lt;Grid
x:Name=&lt;span style="color: #006080"&gt;"LayoutRoot"&lt;/span&gt; Background=&lt;span style="color: #006080"&gt;"White"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum12" style="color: #606060"&gt; 12:&lt;/span&gt; &amp;lt;TextBox
Text=&lt;span style="color: #006080"&gt;"This is a test"&lt;/span&gt; Style=&lt;span style="color: #006080"&gt;"{StaticResource
test}"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum13" style="color: #606060"&gt; 13:&lt;/span&gt; &amp;lt;/Grid&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum14" style="color: #606060"&gt; 14:&lt;/span&gt; &amp;lt;/UserControl&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
If you try to run this it will fail. So how can we set this property in style? Well,
a trick you can use is to set your own attached property and then have the property
set the VerticalScrollBarVisibility property on the TextBox for you. Here is a very
quick example that I cooked up (using &lt;a href="http://blog.nerdplusart.com/archives/silverlight-code-snippets"&gt;Robby&amp;rsquo;s
code snippet&lt;/a&gt;):
&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum1" style="color: #606060"&gt; 1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;namespace&lt;/span&gt; Attachment&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum2" style="color: #606060"&gt; 2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum3" style="color: #606060"&gt; 3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Attachments&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum4" style="color: #606060"&gt; 4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum5" style="color: #606060"&gt; 5:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;readonly&lt;/span&gt; DependencyProperty
MyVsbvProperty =&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum6" style="color: #606060"&gt; 6:&lt;/span&gt; DependencyProperty.RegisterAttached(&lt;span style="color: #006080"&gt;"MyVsbv"&lt;/span&gt;, &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum7" style="color: #606060"&gt; 7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(ScrollBarVisibility), &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum8" style="color: #606060"&gt; 8:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(Attachments), &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum9" style="color: #606060"&gt; 9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PropertyMetadata(OnMyVsbvChanged));&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum10" style="color: #606060"&gt; 10:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum11" style="color: #606060"&gt; 11:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetMyVsbv(DependencyObject
o, ScrollBarVisibility &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum12" style="color: #606060"&gt; 12:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum13" style="color: #606060"&gt; 13:&lt;/span&gt; o.SetValue(MyVsbvProperty, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum14" style="color: #606060"&gt; 14:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum15" style="color: #606060"&gt; 15:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum16" style="color: #606060"&gt; 16:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; ScrollBarVisibility
GetMyVsbv(DependencyObject o)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum17" style="color: #606060"&gt; 17:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum18" style="color: #606060"&gt; 18:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (ScrollBarVisibility)o.GetValue(MyVsbvProperty);&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum19" style="color: #606060"&gt; 19:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum20" style="color: #606060"&gt; 20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum21" style="color: #606060"&gt; 21:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnMyVsbvChanged(DependencyObject
d, DependencyPropertyChangedEventArgs e)&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum22" style="color: #606060"&gt; 22:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum23" style="color: #606060"&gt; 23:&lt;/span&gt; ((TextBox)d).VerticalScrollBarVisibility
= (ScrollBarVisibility)e.NewValue;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum24" style="color: #606060"&gt; 24:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum25" style="color: #606060"&gt; 25:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum26" style="color: #606060"&gt; 26:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Very unintuitive name and my casts could be bad since there are no type checks, just
an example. So here when the attached property is changed we change the property on
the TextBox that the property is declared on. So if we change our style to use the
attached property instead of the actual property it will work: 
&lt;/p&gt;
&lt;div id="codeSnippetWrapper" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; width: 97.5%; font-family: 'Courier New', courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; cursor: text; border: silver 1px solid; padding: 4px;"&gt;
&lt;div id="codeSnippet" style="text-align: left; line-height: 12pt; background-color: #f4f4f4; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum1" style="color: #606060"&gt; 1:&lt;/span&gt; &amp;lt;UserControl
x:Class=&lt;span style="color: #006080"&gt;"Attachment.Page"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum2" style="color: #606060"&gt; 2:&lt;/span&gt; xmlns=&lt;span style="color: #006080"&gt;"http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum3" style="color: #606060"&gt; 3:&lt;/span&gt; xmlns:x=&lt;span style="color: #006080"&gt;"http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum4" style="color: #606060"&gt; 4:&lt;/span&gt; xmlns:local=&lt;span style="color: #006080"&gt;"clr-namespace:Attachment"&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum5" style="color: #606060"&gt; 5:&lt;/span&gt; Width=&lt;span style="color: #006080"&gt;"400"&lt;/span&gt; Height=&lt;span style="color: #006080"&gt;"300"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum6" style="color: #606060"&gt; 6:&lt;/span&gt; &amp;lt;UserControl.Resources&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum7" style="color: #606060"&gt; 7:&lt;/span&gt; &amp;lt;Style
TargetType=&lt;span style="color: #006080"&gt;"TextBox"&lt;/span&gt; x:Key=&lt;span style="color: #006080"&gt;"test"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum8" style="color: #606060"&gt; 8:&lt;/span&gt; &amp;lt;Setter
Property=&lt;span style="color: #006080"&gt;"FontSize"&lt;/span&gt; Value=&lt;span style="color: #006080"&gt;"24"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum9" style="color: #606060"&gt; 9:&lt;/span&gt; &amp;lt;Setter
Property=&lt;span style="color: #006080"&gt;"local:Attachments.MyVsbv"&lt;/span&gt; Value=&lt;span style="color: #006080"&gt;"Visible"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum10" style="color: #606060"&gt; 10:&lt;/span&gt; &amp;lt;/Style&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum11" style="color: #606060"&gt; 11:&lt;/span&gt; &amp;lt;/UserControl.Resources&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum12" style="color: #606060"&gt; 12:&lt;/span&gt; &amp;lt;Grid
x:Name=&lt;span style="color: #006080"&gt;"LayoutRoot"&lt;/span&gt; Background=&lt;span style="color: #006080"&gt;"White"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum13" style="color: #606060"&gt; 13:&lt;/span&gt; &amp;lt;TextBox
Text=&lt;span style="color: #006080"&gt;"This is a test"&lt;/span&gt; Style=&lt;span style="color: #006080"&gt;"{StaticResource
test}"&lt;/span&gt; /&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: #f4f4f4; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum14" style="color: #606060"&gt; 14:&lt;/span&gt; &amp;lt;/Grid&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;pre style="text-align: left; line-height: 12pt; background-color: white; margin: 0em; width: 100%; font-family: 'Courier New', courier, monospace; direction: ltr; color: black; font-size: 8pt; overflow: visible; border-style: none; padding: 0px;"&gt;&lt;span id="lnum15" style="color: #606060"&gt; 15:&lt;/span&gt; &amp;lt;/UserControl&amp;gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So there you have it. If you need to style a property on a control that isn&amp;rsquo;t
a dependency property you can use this method to get around that limitation. There
are a bunch of other uses for this that I&amp;rsquo;ll be blogging when I have another
minute. 
&lt;/p&gt;
&lt;p&gt;
Enjoy!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=e34590d7-c194-4b37-affa-f0b6034d6ea8" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,e34590d7-c194-4b37-affa-f0b6034d6ea8.aspx</comments>
      <category>Silverlight</category>
    </item>
    <item>
      <trackback:ping>http://bryantlikes.com/Trackback.aspx?guid=ab51adb8-8277-4ed4-a2fc-1039ca476377</trackback:ping>
      <pingback:server>http://bryantlikes.com/pingback.aspx</pingback:server>
      <pingback:target>http://bryantlikes.com/PermaLink,guid,ab51adb8-8277-4ed4-a2fc-1039ca476377.aspx</pingback:target>
      <dc:creator>Bryant Likes</dc:creator>
      <wfw:comment>http://bryantlikes.com/CommentView,guid,ab51adb8-8277-4ed4-a2fc-1039ca476377.aspx</wfw:comment>
      <wfw:commentRss>http://bryantlikes.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ab51adb8-8277-4ed4-a2fc-1039ca476377</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>Silverlight Streaming Utility Classes</title>
      <guid isPermaLink="false">http://bryantlikes.com/PermaLink,guid,ab51adb8-8277-4ed4-a2fc-1039ca476377.aspx</guid>
      <link>http://bryantlikes.com/SilverlightStreamingUtilityClasses.aspx</link>
      <pubDate>Wed, 11 Mar 2009 16:36:00 GMT</pubDate>
      <description>&lt;p&gt;
Yesterday I was working through &lt;a href="http://silverlight.net/forums/t/78284.aspx"&gt;another
question in the Silverlight Forums&lt;/a&gt; about how to upload video to &lt;a href="http://silverlight.live.com"&gt;Silverlight
Streaming&lt;/a&gt; via code. At first I tried to reference &lt;a href="http://www.codeplex.com/videoshow"&gt;the
Video.Show application&lt;/a&gt;, but there is a lot of code there and it doesn&amp;rsquo;t
help if you just want to upload a bunch of videos to the same application. So I ended
up taking some of the code from Video.Show and some of the code from &lt;a href="http://msdn.microsoft.com/en-us/library/bb851621.aspx"&gt;the
SDK/API&lt;/a&gt; and created a very simple Utility class to help with the process. 
&lt;/p&gt;
&lt;p&gt;
You can &lt;a href="http://code.msdn.microsoft.com/SlStreamingUtils"&gt;download the code
on the Code Gallery site&lt;/a&gt;. It is very simple in that there is no error handling
and I didn&amp;rsquo;t create a Silverlight version yet. I did implement GET, POST, PUT,
MKCOL, and DELETE as well as creating the functionality to package a bunch of videos
into a single zip which can be posted all at once. 
&lt;/p&gt;
&lt;p&gt;
A few examples from the code, first creating a directory and PUTting a file in it:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;WebDavClient client = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebDavClient(&lt;span class="str"&gt;"Your
AppID"&lt;/span&gt;, &lt;span class="str"&gt;"Your Key"&lt;/span&gt;); &lt;span class="rem"&gt;// get those
from http://silverlight.live.com&lt;/span&gt; client.CreateFolder(&lt;span class="str"&gt;"MyVideos"&lt;/span&gt;);
client.PutFile(&lt;span class="str"&gt;"MyVideos"&lt;/span&gt;,&lt;span class="str"&gt;"C:\\videos\reallyCoolVideo.wmv"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;&lt;!--
.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; }
--&gt;&lt;/style&gt;
&lt;style type="text/css"&gt;&lt;!--
.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; }
--&gt;&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;
Next, packaging up a bunch of videos and POSTing the zip as an application:
&lt;/p&gt;
&lt;pre class="csharpcode"&gt;WebDavClient client = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebDavClient(&lt;span class="str"&gt;"Your
AppID"&lt;/span&gt;, &lt;span class="str"&gt;"Your Key"&lt;/span&gt;); &lt;span class="rem"&gt;// get those
from http://silverlight.live.com&lt;/span&gt; client.PackageAndPostFiles(&lt;span class="str"&gt;"MyVideos"&lt;/span&gt;,&lt;span class="str"&gt;"C:\\videos\firstCoolVideo.wmv"&lt;/span&gt;,&lt;span class="str"&gt;"C:\\videos\anothercoolVideo.wmv"&lt;/span&gt;);&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;&lt;!--
.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; }
--&gt;&lt;/style&gt;
&lt;style type="text/css"&gt;&lt;!--
.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; }
--&gt;&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;
Let me know if you&amp;rsquo;d like to see a Silverlight version (be easy to implement)
or if there are any other features you&amp;rsquo;d like added. 
&lt;/p&gt;
&lt;p&gt;
Enjoy!
&lt;/p&gt;
&lt;div class="wlWriterHeaderFooter" style="text-align:right; margin:0px; padding:4px 0px 4px 0px;"&gt;&lt;a href="http://creativecommons.org/licenses/by/3.0/"&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://bryantlikes.com/aggbug.ashx?id=ab51adb8-8277-4ed4-a2fc-1039ca476377" /&gt;</description>
      <comments>http://bryantlikes.com/CommentView,guid,ab51adb8-8277-4ed4-a2fc-1039ca476377.aspx</comments>
      <category>Silverlight</category>
    </item>
  </channel>
</rss>