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

<channel>
	<title>SharePoint Magazine</title>
	<atom:link href="http://sharepointmagazine.net/feed" rel="self" type="application/rss+xml" />
	<link>http://sharepointmagazine.net</link>
	<description>Your Premier Source of SharePoint Information</description>
	<lastBuildDate>Tue, 06 Dec 2011 19:29:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>InnerWorkings Adds SharePoint 2010 to its Learning Platform</title>
		<link>http://sharepointmagazine.net/news/innerworkings-adds-sharepoint-2010-to-its-learning-platform</link>
		<comments>http://sharepointmagazine.net/news/innerworkings-adds-sharepoint-2010-to-its-learning-platform#comments</comments>
		<pubDate>Wed, 19 Oct 2011 17:00:02 +0000</pubDate>
		<dc:creator>bjornadmin</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6651</guid>
		<description><![CDATA[InnerWorkings announced a major addition to its Learning Platform today with the release of self-paced SharePoint 2010 training for professional developers and software teams.]]></description>
			<content:encoded><![CDATA[<p><strong>San Francisco, CA — October 18, 2011.</strong></p>
<p><a href="http://www.innerworkings.com/sharepoint">InnerWorkings</a> announced a major addition to its Learning Platform today with the release of self-paced SharePoint 2010 training for professional developers and software teams.</p>
<p>Working in partnership with the <a href="http://www.uspja.com/">USPJ Academy</a>, InnerWorkings is offering world class SharePoint learning solutions to its customers. USPJA boasts a team of industry renowned SharePoint experts whose approach emphasizes the real-world aspects of learning SharePoint — a perfect fit with the InnerWorkings methodology.</p>
<p>InnerWorkings confirmed the immediate release of three SharePoint courses to its Learning Platform, covering the following topics:</p>
<ul>
<li><em>Beginning SharePoint Development</em></li>
<li><em>SharePoint Data View Web Part Basics</em></li>
<li><em>SharePoint Designer 2010 Workflow</em></li>
</ul>
<p>Additional SharePoint courses are in development and will be released on a quarterly basis. All of the SharePoint courses include video-based instruction from USPJA experts, hand-picked e-books, and a virtual lab environment to practice important configuration tasks. In addition, a Live Guide feature connects developers and in-house SharePoint experts to facilitate ongoing support and grading of assignments.</p>
<p>“With over 100M users and $1B in revenue for Microsoft, SharePoint is the understated giant of Microsoft’s enterprise collaboration strategy”, said Francis McKeagney, InnerWorkings CEO. “As a server-based technology, SharePoint presents significant challenges to organizations wishing to provide deep, hands-on training to their software teams. We are really excited that our new offering addresses this issue in a rigorous and compelling way. The virtual lab capability, in particular, allows for deep learning in both generic and customizable setups. We are delighted to partner with USPJA to deliver such a comprehensive enterprise learning solution for SharePoint development teams. USPJA’s knowledge and expertise has made this offering possible.”</p>
<p>“The market for SharePoint developers has never been hotter”, said Bjørn Furuknap, USPJA CEO. “We’ve always been extremely confident in the depth and quality of our SharePoint learning solutions, but this partnership with InnerWorkings brings tremendous scale and reach to our efforts. Coupling the technical strength of our training with the online learning expertise and global audience of InnerWorkings is a winning combination. We are delighted to partner with InnerWorkings to offer our combined SharePoint learning services to a huge audience of SharePoint developers and teams hungry to succeed in their chosen area of domain expertise.”</p>
<p><strong>About InnerWorkings</strong><br />
At InnerWorkings, our mission is to help our customers build great software organizations. We believe that it is possible to create a successful, efficient, and cost-effective software organization and sustain it over multiple projects. How do we do this? By providing software executives with an integrated platform to improve learning, collaboration, and software processes across your development teams. The company’s R&amp;D facility is based in Dublin, Ireland and InnerWorkings maintains its corporate headquarters in San Francisco, California. For more information about InnerWorkings and its services, visit <a href="http://www.innerworkings.com/">www.innerworkings.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/news/innerworkings-adds-sharepoint-2010-to-its-learning-platform/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>SharePoint Magazine PDF Edition Issue 4</title>
		<link>http://sharepointmagazine.net/premium/sharepoint-magazine-pdf-edition-issue-4</link>
		<comments>http://sharepointmagazine.net/premium/sharepoint-magazine-pdf-edition-issue-4#comments</comments>
		<pubDate>Mon, 03 Oct 2011 21:00:57 +0000</pubDate>
		<dc:creator>bjornadmin</dc:creator>
				<category><![CDATA[Premium]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6638</guid>
		<description><![CDATA[We are happy to announce that the fourth issue of SharePoint Magazine PDF edition is now available for download. In this edition, beyond the regular articles, columns, and features, we also start a new series where in each issue you will receive one chapter of the full USP Journal issue 2/4 titled SharePoint Web Part [...]]]></description>
			<content:encoded><![CDATA[<p>We are happy to announce that the fourth issue of SharePoint Magazine PDF edition is now available for download. In this edition, beyond the regular articles, columns, and features, we also start a new series where in each issue you will receive one chapter of the full USP Journal issue 2/4 titled SharePoint Web Part Development (a $14.95 value!).</p>
<p>In this issue, among other things, you can read the following articles:</p>
<ul>
<li>SharePoint Maturity Model: Does your intranet sound like a dial tone?</li>
<li>New Column: SharePoint Hegemony with Christan Buckley</li>
<li>Developing your own Silverlight Web Part</li>
<li>SharePoint Web Part Development &#8211; Chapter 1</li>
<li>SharePoint Tidbits for End Users</li>
</ul>
<p>Subscribers may download the issue from <a href="http://sharepointmagazine.net/PDF/SharePoint%20Magazine%20Issue%204.pdf">here</a>.</p>
<p>Thanks to <a href="http://www.sharevis.com/">ShareVis</a>, <a href="http://www.innerworkings.com/">InnerWorkings</a>, <a href="http://en.share-gate.com/">ShareGate</a>, and <a href="http://uspja.com/">USPJ Academy</a> for being sponsors of this issue.</p>
<p>Enjoy!</p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"></div>
<p>If you do not have a paid subscription, you can purchase or renew your subscription from the <a title="Subscriptions" href="http://spm.to/sub">Subscription Page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/premium/sharepoint-magazine-pdf-edition-issue-4/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>Silverlight in SharePoint: Developing Your Own Silverlight Web Part</title>
		<link>http://sharepointmagazine.net/articles/developer/silverlight-in-sharepoint-developing-your-own-silverlight-web-part</link>
		<comments>http://sharepointmagazine.net/articles/developer/silverlight-in-sharepoint-developing-your-own-silverlight-web-part#comments</comments>
		<pubDate>Mon, 03 Oct 2011 13:14:35 +0000</pubDate>
		<dc:creator>Karine Bosch</dc:creator>
				<category><![CDATA[Developer]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=5892</guid>
		<description><![CDATA[In SharePoint 2010, we have an out-of-the-box Silverlight web part that can host almost any Silverlight application. But in this fourth part of the Silverlight series, we&#8217;re going to show how to build your own web part that hosts a Silverlight application. In SharePoint 2010, we can develop two different types of web parts: a visual [...]]]></description>
			<content:encoded><![CDATA[<p>In SharePoint 2010, we have an out-of-the-box Silverlight web part that can host almost any Silverlight application. But in this fourth part of the Silverlight series, we&#8217;re going to show how to build your own web part that hosts a Silverlight application.</p>
<p>In SharePoint 2010, we can develop two different types of web parts: a visual web part or a classic web part. With a visual web part, we can design the user interface within an .ascx user control. This control is then loaded in the web part infrastructure when the web part is loaded to the SharePoint page. The .ascx user control is typically deployed to the CONTROLTEMPLATES folder of the SharePoint 14 hive.</p>
<p>The classic web part is the web part we still know from the SharePoint 2007 era. In general, you will develop visual web parts because they are easier to create, but in cases where you have to work with sandboxed solutions, no files can be deployed to the file system, so you will have to develop a web part in the classic way.</p>
<h2>Creating Your Own Visual Web Part</h2>
<p>If you need to pass extra information to the Silverlight application that cannot be handled by the out-of-the-box Silverlight application, you can create your own web part. In this article, we will build our own visual web part hosting the services banner we created in the previous article, &#8220;The Silverlight Client Object Model.&#8221; In next article, we will extend that visual web part with a custom tool pane where the user can choose the color of the service item controls. The color picker in this custom tool pane will also be a Silverlight application.</p>
<p>You can create a visual web part using the SharePoint 2010 tools for Visual Studio 2010.</p>
<p><a href="http://sharepointmagazine.net/wp-content/uploads/2011/05/Visual-WebPart-Template.png"><img src="http://sharepointmagazine.net/wp-content/uploads/2011/05/Visual-WebPart-Template.png" alt="Visual WebPart Template" width="686" height="405" /></a></p>
<p>When looking at Solution Explorer, you will see that the Visual Web Part is created with a number of files. The ServicesBannerVisualWebPart.cs class contains the code to load the user control ServicesBannerVisualWebPartUserControl.ascx. It is in this control that the user interface elements will be defined.</p>
<p><a href="http://sharepointmagazine.net/wp-content/uploads/2011/05/Solution-Explorer.png"><img src="http://sharepointmagazine.net/wp-content/uploads/2011/05/Solution-Explorer.png" alt="Solution Explorer" width="365" height="318" /></a></p>
<p>To be able to render a Silverlight application, a number of HTML elements must be added to the page. The Silverlight control itself is an <strong>&lt;object&gt;</strong> tag that must be rendered within a <strong>&lt;div&gt;</strong> element with a well-defined width and height. This width and height can be relative or absolute. Also, the <strong>&lt;object&gt;</strong> element must specify a width and height; otherwise, the Silverlight application will not be visible. The <strong>&lt;object&gt;</strong> element contains a number of <strong>&lt;param&gt;</strong> elements with name and value attributes.</p>
<ul>
<li><strong>source</strong>: The value indicates the location of the Silverlight application. The out-of-the-box Silverlight application lets you specify your own location, but this example specifies the Silverlight application from the previous article, which is located in the XAPS library.</li>
<li><strong>initParams</strong>: The value of this element depends on which information you want to pass to the Silverlight application when it initializes. The services banner requests that the name of the Service Offering list is passed, but this value is constructed dynamically when the web part loads, which is the reason for the value=&#8221;&lt;%= InitParameters %&gt;&#8221; /&gt; notation.</li>
<li>the <strong>minRuntimeVersion </strong>and <strong>autoUpgrade </strong>attributes are also required, but their values are predefined and cannot be changed by you.</li>
<li>Some Silverlight applications also have an <strong>onError </strong>parameter, requiring a Javascript function treating errors.</li>
</ul>
<pre>   &lt;asp:Panel ID="SilverlightPanel" runat="server" &gt;
     &lt;div id="silverlightControlHost" style="width:100%;height:150"&gt;
       &lt;object id="SLServicesBanner"
               data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"&gt;
           &lt;param name="source" value="/XAPS/Sample2.ServicesBanner.xap"/&gt;
           &lt;param name="initParams" value="&lt;%= InitParameters %&gt;" /&gt;
           &lt;param name="background" value="white" /&gt;
           &lt;param name="minRuntimeVersion" value="4.0.50401.0" /&gt;
           &lt;param name="autoUpgrade" value="true" /&gt;
           &lt;a href="<a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.50401.0">http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.50401.0</a>" style="text-decoration:none"&gt;
              &lt;img src="<a href="http://go.microsoft.com/fwlink/?LinkId=161376">http://go.microsoft.com/fwlink/?LinkId=161376</a>" alt="Get Microsoft Silverlight" style="border-style:none"/&gt;
           &lt;/a&gt;
       &lt;/object&gt;&lt;iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"&gt;&lt;/iframe&gt;</pre>
<pre>     &lt;/div&gt;
   &lt;/asp:Panel&gt;</pre>
<p>The code behind this user control contains a <strong>Page_Load </strong>event. It is this event that is responsible for rendering the Silverlight application. It verifies whether the initParameters variable is properly filled out; if so, the Silverlight application is rendered in a panel. If the <strong>initParameters </strong>value is empty or doesn&#8217;t contain the list parameter, a message is displayed instructing the user to open the web part tool pane in order to fill out the required Silverlight properties. You can use an out-of-the-box JavaScript function to open the tool pane.</p>
<pre>   protected void Page_Load(object sender, EventArgs e)
   {
      if (string.IsNullOrEmpty(initParameters) || !initParameters.Contains("list="))
      {
         SilverlightPanel.Visible = false;
         openEditorPartControl = new LiteralControl(string.Format(
              "To show a Silverlight control &lt;a href=\"javascript:MSOTlPn_ShowToolPane2('Edit','{0}');\"&gt;open the tool pane&lt;/a&gt; and set the Silverlight properties.",
              webPartID));</pre>
<pre>         this.Controls.Add(openEditorPartControl);
      }
      else
      {
         SilverlightPanel.Visible = true;
      }
    }</pre>
<p>The <strong>InitParameters </strong>property is filled from within the <strong>ServicesBannerVisualWebPart.cs </strong>class. While the ascx user control takes care of the rendering of the visual elements, this <strong>ServicesBannerVisualWebPart.cs</strong> class  represents the web part itself. You first have to define a property that can be set from within the tool pane of the web part. It will be displayed in its own category, Silverlight Properties:</p>
<pre>   [System.Web.UI.WebControls.WebParts.WebBrowsable(true),
   Category("Silverlight Properties"),
   DefaultValue(""),
   System.Web.UI.WebControls.WebParts.Personalizable(
   System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
   Description("Specify the InitParams string to initialize the Silverlight application.")]
   public string InitParameters
   {
       get { return initParameters; }
       set { initParameters = value; }
   }</pre>
<p>The web part class also contains the classic <strong>CreateChildControls </strong>method with some predefined code loading the .ascx user control, which is of base type <strong>Control</strong>.</p>
<pre>   protected override void CreateChildControls()
   {
      Control control = Page.LoadControl(_ascxPath);
      Controls.Add(control);
   }</pre>
<p>Because we want to pass information to the <strong>InitParameters </strong>property in the user control, we have to modify this code slightly in order to load and render the more specific <strong>ServiceBannerVisualWebPartUserControl </strong>(a name created by the Visual Studio 2010 templates). When the control is loaded, the web part ID and a value for the <strong>InitParameters </strong>property is passed. The web part ID is needed when the user control needs to display a message that the <strong>InitParameters </strong>property is not properly filled out.</p>
<pre>   protected override void CreateChildControls()
   {
       //Control control = Page.LoadControl(_ascxPath);
       ServicesBannerVisualWebPartUserControl control = this.Page.LoadControl(_ascxPath) as ServicesBannerVisualWebPartUserControl;
       if (control != null)
       {
           control.WebPartID = this.ID;
           control.InitParameters = BuildInitParameters();
           Controls.Add(control);
       }
   }</pre>
<p>The value for the <strong>InitParameters </strong>property is constructed within a private method <strong>BuildInitParameters </strong>and needs an extra word of explanation. As we saw in the previous article, &#8220;The Silverlight Client Object Model,&#8221; you can use the <strong>ClientContext.Current </strong>to get a hold on the SharePoint context. Under the hood, the Silverlight application needs a parameter with name <strong>MS.SP.url </strong>passed in via the InitParameters. When using the out-of-the-box Silverlight web part, this parameter is passed automatically, but when developing your own custom web parts, you have to pass that parameter yourself. If you don&#8217;t pass the parameter <strong>MS.SP.url</strong>, your <strong>ClientContext </strong>will be null.</p>
<p>The <strong>ServicesBanner </strong>Silverlight application also requests the list parameter to be passed, but this one needs to be passed by the user in the tool pane of the custom web part.</p>
<pre>   private string BuildInitParameters()
   {
       if (string.IsNullOrEmpty(initParameters))
          initParameters = "MS.SP.url=" + SPContext.Current.Web.Url;
       else if (!initParameters.Contains("MS.SP.url"))
          initParameters = initParameters + ",MS.SP.url=" + SPContext.Current.Web.Url;</pre>
<pre>       return initParameters;
   }</pre>
<h2>Deploying Your Visual Web Part</h2>
<p>Your web part is now ready to deploy. If you want it to appear in its own category in the Web Part gallery, you will have to modify the <strong>.webpart </strong>file. You can also do the necessary customizations to the feature file. Once your web part is deployed, you can add it to a web part page. You will have to click the hyperlink within the message displayed under the web part title. This is because the <strong>list </strong>parameter is missing from the <strong>InitParameters </strong>string.</p>
<p><a href="http://sharepointmagazine.net/wp-content/uploads/2011/05/Deploy-webpart.png"><img src="http://sharepointmagazine.net/wp-content/uploads/2011/05/Deploy-webpart.png" alt="Click the hyperlink to set the Silverlight properties" width="486" height="49" /></a></p>
<p>When you&#8217;re in the web part tool pane, locate the <strong>Silverlight Properties </strong>section and add the string <strong>list=Services Offering </strong>to the content of the text box. Don&#8217;t forget to add a comma without a whitespace to separate the two parameters:</p>
<p><a href="http://sharepointmagazine.net/wp-content/uploads/2011/05/Custom-tool-pane-property.png"><img src="http://sharepointmagazine.net/wp-content/uploads/2011/05/Custom-tool-pane-property.png" alt="Custom tool pane properties" width="431" height="190" /></a></p>
<p>Click the <strong>Apply </strong>or <strong>OK </strong>button to render the Silverlight application within the web part.</p>
<p><a href="http://sharepointmagazine.net/wp-content/uploads/2011/05/Finished-web-part1.png"><img src="http://sharepointmagazine.net/wp-content/uploads/2011/05/Finished-web-part1.png" alt="Your custom Silverlight webpart" width="765" height="324" /></a></p>
<h2>Conclusion</h2>
<p>In this article, I explained how you can develop your own visual web part to host a Silverlight application. In next article, I will explain how you can create a custom tool pane that hosts a Silverlight color picker.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/articles/developer/silverlight-in-sharepoint-developing-your-own-silverlight-web-part/feed</wfw:commentRss>
		<slash:comments></slash:comments>
	
		<series:name><![CDATA[Silverlight in SharePoint]]></series:name>
	</item>
		<item>
		<title>SharePoint Sense&#8217;s &#8220;SharePoint ShortUrl&#8221;: Size Matters &#8211; Smaller is Better</title>
		<link>http://sharepointmagazine.net/products/sharepoint-senses-sharepoint-shorturl-size-matters-smaller-is-better</link>
		<comments>http://sharepointmagazine.net/products/sharepoint-senses-sharepoint-shorturl-size-matters-smaller-is-better#comments</comments>
		<pubDate>Wed, 28 Sep 2011 17:09:57 +0000</pubDate>
		<dc:creator>Todd Klindt</dc:creator>
				<category><![CDATA[Products]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6610</guid>
		<description><![CDATA[For many years now I have maintained a blog that focuses on SharePoint administration. I use it mainly to document tasks I’ve done or to explain weird behavior of SharePoint. If my mother is to be believed, it could possibly be the best blog on the Internet.]]></description>
			<content:encoded><![CDATA[<p><div class="note"><div class="disclaimer"><span style="font-weight: bold;">Disclaimer: </span>This article is a paid product review and the vendor has paid to have this article published in SharePoint Magazine. The author may have received compensation for writing this article, and SharePoint Magazine has received compensation for publishing it. However, payment for having an article published will not interfere with our strict publishing guidelines and the article has gone through the same or stricter editing processes to ensure accuracy and avoid unduly favorable content.</div></div></p>
<p dir="ltr" align="left">For many years now I have maintained a blog that focuses on SharePoint administration. I use it mainly to document tasks I’ve done or to explain weird behavior of SharePoint. If my mother is to be believed, it could possibly be the best blog on the Internet. Taking my mother’s words to heart, I refer people to my blog often.</p>
<p dir="ltr" align="left">SharePoint’s URLs have always been a bit unwieldy, but for the most part these references were in email or on web pages, where the long, scary URL could be hidden with a hyperlink. Then along came Twitter and URL-shortening services like Bit.ly and tinyurl. Now SharePoint’s long URLs were no longer just unwieldy; they were flat out uncool! Tweets are limited to 140 characters, and a link to one of my blog posts was 59 of those precious characters. Factor in the @ reply characters, and I’d barely have enough space left to explain how great the linked blog post was.</p>
<p dir="ltr" align="left">This was how I got started down the road of investigating URL shorteners in SharePoint and how I arrived at SharePoint ShortUrl from SharePoint Sense.</p>
<p dir="ltr" align="left"><strong>Full Disclosure:</strong></p>
<p dir="ltr" align="left">The story you are about to read is true, and the facts surrounding it are 100 percent accurate. However, I feel I must make it clear that the folks at SharePoint Sense did provide me with a free copy of SharePoint ShortUrl. They also promised me a huge check and Internet stardom for writing this review. I anxiously await both. I did write the article without any input or editorial demands from them. They’re good software developers and all-around good people.<strong><strong></strong></strong></p>
<h1 dir="ltr" align="left">Wandering in the Desert</h1>
<p dir="ltr" align="left">Once I decided that my SharePoint URLs had to go on a diet, I needed to decide which diet was best. First I tried to roll my own. I dusted off my ISO of Visual Studio 2010 and tried, fruitlessly, for several days to cobble together a solution. I even tried wiring something together with query string web parts and bubble gum. No dice. It became clear to me that developing software was complicated work and I should stick to clicking Next a lot and installing SharePoint.</p>
<p dir="ltr" align="left">My next attempt was using the IIS Rewrite tool. This tool is a free add-in for IIS 7 and 7.5 that allows for all kinds of great rewriting functionality. Unfortunately, I wasn’t able to find the correct combination of tools, rules, and guesswork to make it behave the way I wanted. It also saves its configuration to the web.config file, which would mean I’d have to configure each web front end individually. My blog, massive as it is, needs only one WFE for now. But my mom and I have big plans for it, and someday it may require two. Having a solution that scales is important when you’ve got big plans like I do.</p>
<p dir="ltr" align="left">My last futile attempt at URL shortening was to try some free software I found on CodePlex. As with a lot of CodePlex projects, it had some rough edges. It was also written for SharePoint 2007. I contacted the author, and he said it should work find on SharePoint 2010, but he hadn’t tried it. I played with it a little, but it wasn’t very customizable, and I got cut on the rough edges a couple of times. I found some Band-Aids, dried my eyes, and started thinking about Plan B.</p>
<h2 dir="ltr" align="left">Plan B: Letting the Experts Do It</h2>
<p dir="ltr" align="left">After trying to create my own SharePoint URL software, two things were very clear to me. First, I will never be able to feed my family by becoming a software developer. Second, finding software to shorten my SharePoint URLs was best left up to the professionals. I did a few searches to see what solutions already existed. SharePoint ShortUrl from SharePoint Sense kept coming up. I decided to give it a shot. I contacted the chaps at SharePoint Sense, and I was able to sweet talk them into giving me a demo license. I think it was my mom’s recommendation that really sold it. It was on that day that my love affair with SharePoint ShortUrl began.</p>
<p dir="ltr" align="left">While the installation was not simply a WSP solution file to install, it did use a standard SharePoint installer. The installation was painless, and all I really had to tell it was which web applications I wanted the ShortUrl Feature installed to. After the installation was complete, I activated the Feature and started kicking the tires a bit.</p>
<h1 dir="ltr" align="left">Kicking the Tires</h1>
<p dir="ltr" align="left">SharePoint ShortUrl has a few ways you can use it for your URL-shortening needs. You can enable the Features that correspond to the functionality you want. In my case, this was for an anonymously accessed blog, and I needed short URLs only for specific blog posts and various other files. I decided to only activate the Features that allowed me to create one-off short URLs. Figure 1 shows the Features that are scoped at the web level of my blog.</p>
<p dir="ltr" align="left"> </p>
<p dir="ltr" align="left"><img class="alignnone size-full wp-image-6624" title="Figure 1" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/Figure-11.png" alt="" width="680" height="182" /></p>
<p dir="ltr" align="left">Figure 1: Web Scoped Features</p>
<p dir="ltr" align="left">You can see that I’ve activated only one of the Features, ShortUrl Activation. Like the description says, this adds the ShortUrl links to the Site Actions menu and all the document menus, and it’s the basis for all the other ShortUrl functions. With that Feature active, I can now go about creating all the short URLs that I’ve been craving. In my case, the goal was to create short URLs to specific blog posts so they could be easily referenced in places like Twitter. To do that, I just needed to navigate to the blog post itself and click the Site Actions menu and then click &#8220;ShortUrl this page.&#8221; Figure 2 shows the menu options ShortUrl creates.</p>
<p dir="ltr" align="left"><img class="alignnone size-full wp-image-6625" title="Figure 2" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/Figure-21.png" alt="" width="680" height="457" /></p>
<p dir="ltr" align="left">Figure 2: Shortcuts on the Site Actions menu</p>
<p dir="ltr" align="left">After I clicked that menu item, I was taken to the screen in Figure 3. Like any good URL-shortening software, ShortUrl automatically creates a random short URL for the page. It also allows you to replace it with something more meaningful, as I did in Figure 3. You also have the option for assigning an owner of the ShortUrl, and you can make it expire as well. In my case, neither of those made sense, so I left them at their defaults and clicked Save This Url.</p>
<p dir="ltr" align="left"><img class="alignnone size-full wp-image-6626" title="Figure 3" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/Figure-31.png" alt="" width="680" height="466" /></p>
<p dir="ltr" align="left">Figure 3: Creating the ShortUrl</p>
<p dir="ltr" align="left">The folks at SharePoint Sense know that creating the ShortUrl is only part of the battle. In order for the ShortUrl to do anyone any good, you have to be able to share it. That’s where the screen in Figure 4 comes into play. After the ShortUrl is created, you have some options to get out the good word. You can copy the ShortUrl to your clipboard or email it to someone. If you have ShortUrler’s Remorse, you can also delete it, but who would want to do that? To get past this page, you have to click Cancel, which seems odd. Clicking a button that says OK seems like it would make more sense. Clicking Cancel makes you wonder if you aren’t canceling the whole process. I assure you, it doesn’t.</p>
<p dir="ltr" align="left"><img class="alignnone size-full wp-image-6617" title="Figure 4" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/Figure-4.png" alt="" width="591" height="303" /></p>
<p dir="ltr" align="left">Figure 4: Sharing the ShortUrl</p>
<p dir="ltr" align="left">After you click Cancel, you’re taken back to the page you ShortUrled. In my case, that was a blog post. That’s all there was to it. At that point, I leaned back, put my feet up on my desk, and basked in the afterglow of the victory of finally successfully shrinking a SharePoint URL.</p>
<p dir="ltr" align="left">As we’ve seen, creating ShortUrls for blog pages is a pretty simple task. Creating ShortUrls for documents or list items is just as simple. Figure 5 shows the how the item drop-down menu includes new links for the ShortUrl software. Clicking them walks you through the same pages we saw in the figures earlier.</p>
<p dir="ltr" align="left"><img class="alignnone size-full wp-image-6627" title="Figure 5" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/Figure-51.png" alt="" width="680" height="361" /></p>
<p dir="ltr" align="left">Figure 5: ShortUrls are for documents, too.</p>
<h1 dir="ltr" align="left">Managing ShortUrls</h1>
<p dir="ltr" align="left">I was impressed with many aspects of ShortUrl. One of those aspects is that SharePoint ShortUrl is written as SharePoint software, and it stores all the ShortUrls as items in a SharePoint list. When the ShortUrl Feature is activated at the Web Application scope, a list named &#8220;shorturl&#8221; is created at the root of the web application. That list stores all the ShortUrls and allows some management of them. Figure 6 shows the shorturl list from my website. Not only does this list give you the obvious information about the ShortUrl, like the ShortUrl and where it points, but it also adds a HitCount column, as well as a link to open the URL. If you want to delete a ShortUrl, you can simply delete it from this list, like you would any other SharePoint list item. Backing up SharePoint also backs up all your ShortUrls, so there’s nothing new to add there.</p>
<p dir="ltr" align="left"><img class="alignnone size-full wp-image-6628" title="Figure 6" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/Figure-61.png" alt="" width="680" height="439" /></p>
<p dir="ltr" align="left">Figure 6: The shorturl list</p>
<h1 dir="ltr" align="left">Support</h1>
<p dir="ltr" align="left">It’s a sad fact, but software isn’t perfect. OSs have exploits that need to be patched, browsers have security holes to close, and for some reason my MP3 player refuses to play Barry Manilow songs. While it would be great if software didn’t have bugs, that expectation isn’t realistic. With that in mind, when I’m evaluating software, or hardware for that matter, I always try to get an idea what the service on that software will be. SharePoint Sense exceeded my expectations in this regard. When I was testing their software, I noticed a bug. When an anonymous user clicked a ShortUrl, they were prompted for authentication. After some testing, it turned out this was because of how ShortUrl updated the Hit Count for the ShortUrl. ShortUrl was not written for anonymous sites in mind. It was written with internal users in mind, I was trying to use the software in a way it wasn’t necessarily intended. I reported that to the SharePoint Sense folks and thanked them for allowing me to test their software, but unfortunately it wasn’t a good fit. About a week later I got an email back from them; they had fixed the bug and wanted me to take another look at the software. I was amazed by this. Not only was my use case not what the software was designed for, but even if I loved the software, they had given me a free license, so there was no money in it for them. The only thing they stood to gain was my undying gratitude and admiration. The fact that they followed up on it makes me think they’ll attack any other bugs they find with the tenacity of a British bulldog.</p>
<h1 dir="ltr" align="left">Convinced Yet?</h1>
<p dir="ltr" align="left">I’m a big fan of the ShortUrl software. It does exactly what I want, and it does it easily and without any negative side effects that I’ve discovered. Now the URLs for my blog that I put on slides at conferences or on Twitter are smaller, look better, and are easier to remember. As a SharePoint consultant, I routinely recommend ShortUrl software for customers who are looking to give SharePoint a more professional appearance.</p>
<p dir="ltr" align="left">Read more about SharePoint ShortUrl at the web site <a href="http://sharepointshorturl.com/" rel="nofollow" target="_blank">http://sharepointshorturl.com/</a></p>
<p dir="ltr" align="left"><div class="note"><div class="disclaimer"><span style="font-weight: bold;">Disclaimer: </span>This article is a product review and the vendor has paid to have this article published in SharePoint Magazine. The author may have received compensation for writing this article, and SharePoint Magazine has received compensation for publishing it. However, payment for having an article published will not interfere with our strict publishing guidelines and the article has gone through the same or stricter editing processes to ensure accuracy and avoid unduly favorable content.</div></div></p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/products/sharepoint-senses-sharepoint-shorturl-size-matters-smaller-is-better/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>Taking Control of Governance</title>
		<link>http://sharepointmagazine.net/columns/sharepoint-hegemony/taking-control-of-governance</link>
		<comments>http://sharepointmagazine.net/columns/sharepoint-hegemony/taking-control-of-governance#comments</comments>
		<pubDate>Mon, 26 Sep 2011 13:59:39 +0000</pubDate>
		<dc:creator>Christian Buckley</dc:creator>
				<category><![CDATA[SharePoint Hegemony with Christian Buckley]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6562</guid>
		<description><![CDATA[If your engineering team is building your governance plan, you’re doing it wrong. Admit that you have no idea what governance is and that you are powerless. It’s the first step in the 12-step program toward governance sobriety, and I’m here to help you through it.]]></description>
			<content:encoded><![CDATA[<p>If your engineering team is building your governance plan, you’re doing it wrong.</p>
<p>The first mistake you made was ignoring the advice you received from Microsoft, from your consultants, and from the expert community, to build out a governance strategy as part of your overall SharePoint planning. Like flood insurance, most people don’t think about governance until they’re waist-deep in SharePoint sprawl and waking up at night in a cold sweat with change management nightmares. Don’t get me wrong—you probably have really smart administrators and developers who know the technology inside and out. And yet here you are, wondering how you’re going ever to clean up, get things organized, and get your SharePoint environment back on track.</p>
<p>There’s the real issue. In your head you’re thinking “Yeah, I need to insert some governance, and that’ll fix everything.” But you have no idea what it is. Or where to start. Or whether the things you do now will have any impact.</p>
<p>The fact is that governance has less to do with the technology and more to do with defining your goals for the system and how you plan to proactively manage SharePoint toward meeting those goals. Governance has as much to do with defining the business values you’d like to achieve as the day-to-day tactical steps of monitoring and managing your platform. But most companies don’t think this broadly. They see it as a set of policies and procedures around things such as content database size, permissions management, and compliance monitoring. If you’re like most companies, you don’t have a plan for how you engage with your users, you don’t have a method for tracking and measuring the value of your SharePoint initiatives, and you don’t have a procedure for how to engage with your leadership team. But those are all critical aspects of a successful governance strategy.</p>
<p>So, admit it. Admit that you have no idea what governance is and that you are powerless. It’s the first step in the 12-step program toward governance sobriety, and I’m here to help you through it.</p>
<h1>Seek to Understand</h1>
<p>Everyone is talking about SharePoint governance these days. The topic is popping up at SharePoint events around the globe, with the search term SharePoint governance returning 3,220,000 results on Bing. Even those who are known more for their deep technical expertise are being drawn into the conversation and are sharing their limited perspectives on what governance means to them and how it should be managed (usually at a very granular level) within SharePoint.</p>
<p>Your corporate governance strategy is an organized, orderly way to approach business problems and quickly come to an agreement on solutions. In a perfect system, it would be part of your company culture, where everyone is involved (at some level) in the decisions being made around IT. Unfortunately, most governance models fall short of what is needed for the organization, if it exists at all.</p>
<p>The primary reason governance has become the topic du jour is because of the SharePoint history associated with end user adoption. We are having a discussion at this point in SharePoint’s maturity because the platform has grown so rapidly—both as a product in Microsoft’s portfolio and within the organizations where it has been embraced by passionate end users. Although sales of SharePoint licenses may be reaching a certain saturation level, licenses sold don’t always equal platform deployed, much less end users fully engaged. As user adoption increases, the platform reaches the limits of its default settings, introducing concerns around managing and scaling the platform, business productivity, and, inevitably, governance issues. More end users on the platform + more activity per user = more companies needing to think about proper SharePoint management and governance.</p>
<p>The purpose of governance in an organization is to create a decision support system to encourage desirable behaviors in system usage. Properly designed governance models follow a specific strategy, such as better customer responsiveness, improved innovation, or identification and measurement of the cost effectiveness of your IT programs. Successful organizations are proactive in their design and use of a governance infrastructure, including committees, financial reviews, approval workflows, and other organizational tools that drive the decision-making process. An effective governance model will help your company manage and measure your systems and will play a significant role in helping your IT organization perform its role in the company’s competitive strategy.</p>
<p>A broad governance model also helps the organization to recognize cost, time, and technology benefits across the entire system, instead of requiring teams and business units to track and measure on their own—which can lead to imbalanced and improper resource allocations. A properly constructed and executed governance framework provides your company with a decision support system for managing IT projects successfully.</p>
<p>We’ve all heard the complaints: “We spend so much time on process, but I just don’t see any value here,” or “I’m not going to waste another dime on this black hole.” Your governance framework should be one of the core components of your organizational nervous system. These kinds of comments may indicate poor visibility into the process or—more likely—an immature (or nonexistent) governance model. As with any business activity, building without a clear purpose, defined roles, and some sense of what the end result should look like might just be a big black hole.</p>
<h1>Value Creation</h1>
<p>Many organizations have a difficult time evaluating the business value of their IT projects. Expanding SharePoint may fall under this description and raise questions from the business—whether adding new servers to improve performance (Do we really need to buy more hardware?), add new or improved functionality (Why do we need FAST? Doesn’t SharePoint already include search?), or customize SharePoint to meet specific business needs (Why are we building that in SharePoint when we can go buy another tool?). Historically, IT organizations cannot readily demonstrate the return on investment for these activities, which impacts executive buy-in as well as end-user support. Executives want to see that they are getting the biggest bang for their buck. End users want to know that the tools you provide will solve their business needs. You want a way to demonstrate value to both.</p>
<p>Value comes from three activities:</p>
<ul>
<li>By incremental improvements to the system over time</li>
<li>By stretching your team, your processes, and your technology to meet customer demands.</li>
<li>By responding to competitive demands</li>
</ul>
<p>But it can be difficult to measure these values prior to development. While SharePoint offers a quick and relatively inexpensive way to build out a proof of concept (PoC) before going down the path of a full-blown development effort, you still need a way to identify the problem to be solved, organize and articulate the measurements, and then drive the review process.</p>
<p>There are some key components to successful governance:</p>
<ul>
<li>For one, it requires <strong>senior management leadership</strong>. They must understand and agree to the framework and drive accountability through all levels by following the recommendations that come out of the framework. Nothing will cause your process to lose legitimacy more quickly than the executive override.</li>
<li>On that note, <strong>the process should be transparent</strong> so that everyone understands and follows the process and gets behind the end result.</li>
<li>Following closely on the heels of transparency is a <strong>change management</strong> mechanism, which is the key to gaining end-user support. Give people a voice, and they are more likely to accept the changes that occur.</li>
<li>Successful governance <strong>empowers decision making at lower levels</strong>, distributing accountability and control broadly to the teams that own the action—and are impacted by the decisions that are made.</li>
<li>Finally, governance frameworks should be <strong>continually improved</strong> so that users don’t “game” the system and so gaps can be filled as they are identified. Transparency here is also essential—tweaks and changes to the process should also be visible and broadly communicated.</li>
</ul>
<p>A successful governance framework helps show value by providing a framework through which these POCs can be tracked, measured, and evaluated to help demonstrate value. It provides a common denominator—a sandbox, if you will—for system planning.</p>
<h1>Governance Applied</h1>
<p>For the most part, governance has absolutely nothing to do with SharePoint. These are the same rules and procedures that should be in place for every enterprise application or system. Your SharePoint governance activities should be a reflection of your broader IT governance framework, allowing you to trace the path between SharePoint activities and your high-level corporate strategies.</p>
<p>Corporate governance influences many factors within IT, and a strong IT governance model will help your organization to effectively manage SharePoint, influencing/managing/enforcing the following:</p>
<ul>
<li>How SharePoint is used within the organization</li>
<li>How SharePoint is architected</li>
<li>How SharePoint infrastructure is deployed</li>
<li>How SharePoint meets specific business requirements</li>
<li>How the company invests in and prioritizes SharePoint requests</li>
</ul>
<p><em>How</em> you execute your governance strategy inside SharePoint depends entirely on the details surrounding your corporate and IT governance framework. The reality is that some of the decisions you make about how to manage SharePoint will be very difficult to execute based on certain technology limitations in the platform. Although these granular items are not the point of this introductory article, I will be addressing some of these things in future articles.</p>
<p>The goal of this article has been to help you understand the what about governance. My next installment will address the who.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/columns/sharepoint-hegemony/taking-control-of-governance/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>Great Benefits to SharePoint Site Definitions</title>
		<link>http://sharepointmagazine.net/articles/great-benefits-to-sharepoint-site-definitions</link>
		<comments>http://sharepointmagazine.net/articles/great-benefits-to-sharepoint-site-definitions#comments</comments>
		<pubDate>Sun, 25 Sep 2011 17:27:26 +0000</pubDate>
		<dc:creator>Jennifer Branham</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Short and to the SharePoint]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6479</guid>
		<description><![CDATA[The popularity of SharePoint as a collaboration tool has understandably skyrocketed in recent years. With its sheer volume of user empowerment, the collaborative adoption scenarios are almost endless. However, the novelty of elevated user empowerment can quickly erode if you are required to maintain any sort of control, standardization, or guidance for your SharePoint environment. [...]]]></description>
			<content:encoded><![CDATA[<p>The popularity of SharePoint as a collaboration tool has understandably skyrocketed in recent years. With its sheer volume of user empowerment, the collaborative adoption scenarios are almost endless. However, the novelty of elevated user empowerment can quickly erode if you are required to maintain any sort of control, standardization, or guidance for your SharePoint environment. For those first starting to tackle SharePoint head on, this is a daunting task. Several different means are available to help you gain the upper hand in your environment. One such avenue is the deployment and use of site definitions.</p>
<h1>What Is a Site Definition?</h1>
<p>The best way to think about site definitions is to envision them as master site templates for your SharePoint environment. No, these aren’t the site templates you find in your site collection’s template gallery. The site templates you create and store in your gallery have their place in SharePoint processes but are localized to the site collection level. Site definitions are holistic to the entire environment. They can standardize your SharePoint look, feel, operation, and purpose. Consider Microsoft’s PowerPoint application. Once installed, you can use PowerPoint, but you’ve got nothing in there but a plain, white master slide. Even more critically, your presentations lack direction. Now apply master slides, and you get a standard look, feel, and purpose for your presentation. SharePoint is much the same. Upon installation, you’ve got a few standard out-of-the box definitions (team sites, blank sites, meeting workspaces, and so on) that are packed with all the collaborative capabilities you need at your fingertips, but they are not tailored for your business. By customizing existing site definitions or creating and adding new ones, you can create the master templates you’ll need to make SharePoint work for your company.</p>
<h1>How Do These Site Definitions Work?</h1>
<p>In a nutshell, when you create a new site, SharePoint will reference a master list of site definition configuration files. From there, it looks for the selected WEBTEMP.xml file and the respective folder containing the actual site definition.</p>
<p>This will give you a new site that appears to have its own unique pages. However, the pages are actually shared across all sites that use that definition. When you customize site definitions for your company, you are actually duplicating the WEBTEMP.xml file, renaming it, assigning it a new ID, and creating its matching site definition directory in the proper location along with all the changes you want for that specific definition. This allows it to be referenced during the site provisioning process. As a result, you are using this referencing process to optimize SharePoint’s performance by minimizing duplicate files, which are often referenced as “unghosted” sites.</p>
<p>Site definitions are stored in the following location:</p>
<p>C:\Program Files\Common Files\Microsoft Shared\webserver extensions\60\Template\SiteTemplates</p>
<p>The WEBTEMP file is stored in the following location:</p>
<p>C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\Template\1033\XML</p>
<p>Here’s the winning difference between site definitions and site templates. Along with performance optimization, SharePoint site definitions are a very powerful way of ensuring that updates and changes reach all your sites. For example, if you create 100-plus sites using the same site definition, you can then push out any changes, such as a new logo, new content type, and so on, to all sites by updating a single .aspx file. The opposite would be true for site templates where each site created with the site template would have to be updated individually.</p>
<p>Numerous components of a site definition are available for customization. Some of these include the following:</p>
<ul>
<li>Branding: The general look and feel of the site, including logos, color schema’s graphics, and more.</li>
<li>Site provisioning: The available site definitions that can be referenced as subsites. This proves useful for industries wanting to centrally locate certain sites with specific purposes.</li>
<li>Permission levels: Many companies find the permission levels inside a standard site unnecessary and not applicable to their governance or business needs. Custom site definitions can remove unnecessary permission levels and add new ones.</li>
<li>Site columns: Some industries are subject to mandatory compliance standards, such as the Privacy Act, security classifications, and more. Many of the out-of- box site columns cannot be used in these industries. Site definition enables you to remove unwanted site columns and add custom ones that are better suited for your business’ needs.</li>
<li>Content types: Standardize your content types and tailor them for your environment.</li>
<li>SharePoint groups: Provides a blueprint for which groups are created and what permission levels are automatically applied to those groups.</li>
</ul>
<p>There are a lot of standard approaches to customizing site definitions. When considering what should go into a new site definition, it is best to first evaluate what comes standard with the out-of-box site definitions. Then, you can remove any unwanted materials and add where needed.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/articles/great-benefits-to-sharepoint-site-definitions/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>Why Lists and Libraries Make No Sense in SharePoint</title>
		<link>http://sharepointmagazine.net/articles/why-lists-and-libraries-make-no-sense-in-sharepoint</link>
		<comments>http://sharepointmagazine.net/articles/why-lists-and-libraries-make-no-sense-in-sharepoint#comments</comments>
		<pubDate>Mon, 19 Sep 2011 16:50:20 +0000</pubDate>
		<dc:creator>Bjørn Furuknap</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6534</guid>
		<description><![CDATA[No, we have not turned completely mental, but I am opposed to the idea that we use storage location to categorize data. Let me tell you what I mean.]]></description>
			<content:encoded><![CDATA[<p>I can still count to five. 1. 2. 3. 4. 5.</p>
<p>I know my own name: Bjørn Furuknap (technically, it’s Bjørn Christoffer Aulie Thorsmæhlum Furuknap).</p>
<p>I am currently sitting in my home office in Oslo, Norway, and it’s Monday afternoon (5ish p.m.).</p>
<p>So, I am not mad, at least not more than usual, but I’ll still argue that lists and libraries make no sense in SharePoint.</p>
<h1>SharePoint Lists and Libraries as Taxonomy Features Considered Harmful!</h1>
<p>Before we become further acquainted, let me clarify the title slightly. Lists and libraries are mandatory in SharePoint, but you should never use them to classify content. Let me elaborate on what that means.</p>
<p>Before the days of content management, we had file shares, with the idea of storage <em>location</em> as the taxonomy option of choice. After all, beyond filenames, storage location was the only option.</p>
<p>The idea was as simple as it was a bad idea. You created hierarchies of drives, shares, and folders to structure the content you wanted to store. Put your content inside said folders, and <em>poof</em>, you had an archive of sorts.</p>
<p>However, when you stop to think about it, this is an incredibly stupid idea. Consider the following folder structure, epitomizing the idea of location as taxonomy:</p>
<p><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border-width: 0px;" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/SharePointListsAreBad01_thumb.png" alt="SharePointListsAreBad01" width="232" height="150" border="0" /></p>
<p>Essentially, you start at the root with a Clients folder, containing in turn one folder per client, which in turn contains folders for the various types of documents.</p>
<p>This isn’t a bad idea, but the implementation is horrible.</p>
<p>First, this structure makes it very difficult to find all the invoices for all the clients, except if you were to use filenames as an additional taxonomy element (in itself a rather ludicrous idea, but I’ll get to that in a moment). The problem is that you can only ever store a file in one location, so if a file needs two taxonomy definitions, for example being classified both by type (invoice) and by year (2010), you’re out of luck.</p>
<p>Granted, there are ways around these issues. You could use the created date of the file to classify it by year, hoping that nobody ever copies the file to a different location. In Windows, you can also use shortcuts, or in Linux a symlink, but basically those options force you to retain a file in a specific location forever, lest the links break loose, along with all hell.</p>
<p>Second, and this is the important bit, you say that “Inside this folder are invoices,” but frankly, it’s only the discipline of users that makes this true. Were I or anyone to put images of my pets inside those folders, those pictures wouldn’t turn into invoices, would they? Of course not, that’s a silly idea! Everything remains what it is, regardless of where you store it.</p>
<h1>A Coffee Cup Is a Coffee Cup</h1>
<p>Let me explain with another example. On my desk I usually have at least two glasses of water, and I mostly keep them together on the left side of my desk. The glasses contain water, which glasses of water usually do. Nothing magical or earth-shattering, really.</p>
<p>I also drink at times insane amounts of coffee, even for a Norwegian. When I’m working actively, I often drink 15 to 20 cups per day. I keep my cup of coffee on the right side of my desk, simply because drinking coffee is more of a ceremony and requires more attention than drinking water, and thus I want to interrupt whatever it is I am doing while drinking coffee. When I need to use my right hand, that means I can’t use the mouse while drinking coffee, creating a natural break, albeit only for a few seconds.</p>
<p>However, if I were to change this scheme, and to be honest I often do, it would not create chaos. My coffee wouldn’t suddenly turn into water simply because I put the coffee container where the water container usually resides. The break I need to take to avoid burning my lips off is still required of the coffee but not of the water. The coffee doesn’t change simply by putting it in another location. It is what it is.</p>
<h1>That’s Why We Have Filenames!</h1>
<p>In the previous folder example, we can assume that something is not an invoice if it was named something like “Pet Picture 0001.jpg,” even if it was stored inside the invoices folder. Similarly, we can assume that something is an invoice if it was called something like “Invoice 0001.pdf.” We’ve been doing this for decades, identifying file contents based on the names.</p>
<p>The use of filenames and our incredibly naïve trust of filenames as indications of content is a problem, though, because the filename isn’t at all a decisive factor in the content of the file. If I were to put a Post-it note on my coffee cup with the words “Glass of Water,” the coffee cup would still remain a coffee cup. If you name your pet pictures “Invoice 000N.jpg,” they are still pet pictures.</p>
<p>However, most of us would still blindly believe that the content was an invoice and happily open the file. This has been used successfully by malware authors also for decades, for example in the Anna Kournikova virus, where recipients were tricked to believe that a file with a certain name contained certain content. It did not.</p>
<p><div class="note"><div class="noteclassic">An old nerd joke says that true nerds never take backups; they only zip their drives, name the zip file “Britney Spears Nude.zip,” and share the file on Kazaa.</div></div></p>
<p>Filenames, in fact, are also rather ancient and should not be necessary.</p>
<h1>Fine, They’re Documents!</h1>
<p>Hold your horses a bit. In SharePoint, with a team site, we get a Shared Documents library. We can create additional document libraries extremely easily. However, this is actually just as silly, once you start thinking about it.</p>
<p>Most organizations work to a much greater extent with logical entities than they work with documents. An employee isn’t a document nor are the lunchroom chairs or the CEO’s parking space. Our clients aren’t documents nor are the invoices we send.</p>
<p>“Hold on!” I hear you say, with my superhuman hearing, knowing full well that you likely didn’t even think that. “An invoice is exactly a document, and it’s what I send!”</p>
<p>Well, you may think you send invoices as documents, but in fact, those documents are really just manifestations of the entity that is the invoice. The invoice itself is actually defined as several metadata properties, such as the invoice number, the line items, the sum, and the due date. Those pieces of metadata are the actual invoice; the paper on which you print the invoice is simply a carrier of that metadata information.</p>
<p>In fact, prior to printing specific metadata information on it, the paper is simply pulp. Without the specific pieces of metadata required to make the paper an invoice, the only way you can categorize the paper is by “Paper.” Imagine the archiving nightmare if everything was simply categorized as that.</p>
<p><img style="padding-left: 0px; padding-right: 0px; padding-top: 0px; border: 0px;" src="http://sharepointmagazine.net/wp-content/uploads/2011/09/SharePointPaperArchive_thumb.png" alt="SharePointPaperArchive" width="322" height="428" border="0" /></p>
<p>Calling something paper is about as useful as calling something a document. It adds absolutely nothing of value, no more than calling something “an item.” That’s why I hate the idea of having “Shared Documents” in a team site.</p>
<p>Consider this: replace the word <em>Document</em> from use in SharePoint with the word <em>Paper</em>. Both are equally meaningless in a taxonomy sense. Doing so leaves you with “Shared Paper,” a “Paper Library,” “Paper Sets,” and “Paper Information Panel.” See how silly it sounds?</p>
<p>Granted, there is a slight different between paper and document, but the point remains; neither says anything about the contents and describes only the form or carrier.</p>
<h1>So, What’s So Perfect Then?</h1>
<p>The purpose of this article is primarily to show you how ridiculous the idea of location as a taxonomy feature really is and additionally show you how the default mind-set of many SharePoint installations really serves more to confuse than to clarify. We shouldn’t work with “documents” anymore; we should work with “Invoices,” “Contracts,” “Clients,” and “Employees.”</p>
<p>For this purpose, SharePoint has the coolest little invention called <em>content types</em>. In essence, content types are, you guessed it, types of content, such as “Invoices,” “Contracts,” “Clients,” and “Employees.” In fact, if you’re curious about what these weird little creatures really are, there’s already an article on SharePoint Magazine titled “SharePoint Content Types:  Why Should I Care?”</p>
<p><div class="note"><div class="notetip">Read “SharePoint Content Types:  Why Should I Care?” here:</p>
<p><a title="http://sharepointmagazine.net/articles/sharepoint-content-types-why-should-i-care" href="http://sharepointmagazine.net/articles/sharepoint-content-types-why-should-i-care">http://sharepointmagazine.net/articles/sharepoint-content-types-why-should-i-care</a></p>
<p></div></div></p>
<p>In closing, however, I would like to mention this: in most of the projects in which I am involved, I end up creating custom lists and document libraries far more than any of the other types of lists and libraries. I’ll talk more about that in a future article. <img src='http://sharepointmagazine.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>.b</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/articles/why-lists-and-libraries-make-no-sense-in-sharepoint/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
		<item>
		<title>A jQuery Primer for SharePoint: Events and Effects</title>
		<link>http://sharepointmagazine.net/articles/a-jquery-primer-for-sharepoint-events-and-effects</link>
		<comments>http://sharepointmagazine.net/articles/a-jquery-primer-for-sharepoint-events-and-effects#comments</comments>
		<pubDate>Thu, 15 Sep 2011 14:43:35 +0000</pubDate>
		<dc:creator>Marc D. Anderson</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6518</guid>
		<description><![CDATA[As your users interact with SharePoint pages in their browser, various events occur. The most familiar to you might be the click event or the hover event. In the fourth part of this series, we'll explore how to work with these events.]]></description>
			<content:encoded><![CDATA[<p>In previous articles, I have covered how you find things in the DOM and manipulate them; now let&#8217;s think about reacting to user actions with events and effects.</p>
<ul>
<li>jQuery Core</li>
<li>Selectors</li>
<li>Attributes</li>
<li>Traversing</li>
<li>Manipulation</li>
<li>CSS</li>
<li><strong>Events</strong></li>
<li><strong>Effects</strong></li>
<li>Ajax</li>
<li>Utilities</li>
<li>jQuery UI</li>
</ul>
<h3>Events</h3>
<p>As your users interact with pages in their browser, various events occur. The most familiar to you might be the click event or the hover event. However, the JavaScript event model provides you with a whole range of events into which you can hook your own script. This lets you set things up so that the page reacts to what the user is doing. You see this all the time on web pages, but may not give much thought to how it actually works. jQuery builds upon the JavaScript event model, providing a clean abstraction and making it far easier to react to events.</p>
<p>The JavaScript events that are available to you for any particular element in the DOM vary with the element&#8217;s type. You will want to learn what events are available for each type of element, because not all events are available for all elements. I frequently use the <a href="http://www.w3schools.com/js/">w3schools.com</a> site to look up information about JavaScript events (and many other things), if you are looking for a good reference.</p>
<p>Let&#8217;s take a look at a simple example, as usual. Say that you would like to show the user an alert when they click the title of a web part (not terribly practical, but it shows the concept). The following code selects for the web part titles on the page—yes, all of them at once—and then binds to the click event for those H3 elements. When the user clicks any of the titles, they will see the alert.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #FCFFBA;color: black;">$<span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;h3.ms-WPTitle&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">click</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #003366; font-weight: bold;color: #577A61;color: blue;">function</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span> <span style="color: #009900;color: #CCC;color: black;">&#123;</span>
&nbsp;
<span style="color: #000066;color: #8FB394;color: blue;">alert</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;You'll now be taken directly to the list.&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span>
&nbsp;
<span style="color: #009900;color: #CCC;color: black;">&#125;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span></pre></div></div>

<p>The same script should work in SharePoint 2007 or 2010. In addition, if the title is a hyperlink to the default list view, they will still end up there after they close the alert.</p>
<p>That is a basic little example, but it should show you how you could start to think about what a user does in their browser and how you might want the page to react to those actions. We could choose to bind to different events for the same web part title, too. For instance, if we replace &#8220;click&#8221; with &#8220;mouseover,&#8221; then we will get the alert whenever we put the cursor over the text.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #FCFFBA;color: black;">$<span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;h3.ms-WPTitle&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">mouseover</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #003366; font-weight: bold;color: #577A61;color: blue;">function</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span> <span style="color: #009900;color: #CCC;color: black;">&#123;</span>
&nbsp;
<span style="color: #000066;color: #8FB394;color: blue;">alert</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;You just put your cursor on me.&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span>
&nbsp;
<span style="color: #009900;color: #CCC;color: black;">&#125;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span></pre></div></div>

<p>You can see all of the available events on the <a href="http://api.jquery.com/category/events/">Events documentation page</a> on the jQuery site.</p>
<h3>Effects</h3>
<p>With effects, you can make things happen, like you can by changing element attributes. jQuery&#8217;s effects may be what most people think of when they hear about jQuery. They include such nice stuff as fading in or out, sliding up or down, and animation. These effects are difficult to show you in a text article, so you&#8217;ll have to take my word for some things, but even better, you should try them yourself.</p>
<p>Showing an alert like I did previously is not likely to be a big goal; instead, you can execute any script you want in the function you have bound to the event. For instance, you might want to expand or collapse part of the visible page content based on the user&#8217;s click. This is where effects can come in.</p>
<p>Take a look at this example code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #FCFFBA;color: black;">$<span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;h3.ms-WPTitle&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">find</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;nobr&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">unwrap</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;&amp;lt;a&amp;gt;&amp;lt;/a&amp;gt;&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span>
&nbsp;
$<span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;h3.ms-WPTitle&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">click</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #003366; font-weight: bold;color: #577A61;color: blue;">function</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span> <span style="color: #009900;color: #CCC;color: black;">&#123;</span>
&nbsp;
$<span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #000066; font-weight: bold;color: #B83A24;color: blue;">this</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">closest</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;table&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">closest</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #3366CC;color: #666666;color: maroon;">&quot;tr&quot;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">next</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span>.<span style="color: #660066;color: black;">toggle</span><span style="color: #009900;color: #CCC;color: black;">&#40;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span>
&nbsp;
<span style="color: #009900;color: #CCC;color: black;">&#125;</span><span style="color: #009900;color: #CCC;color: black;">&#41;</span><span style="color: #339933;color: #CCC;color: black;">;</span></pre></div></div>

<p>Here I am first removing the hyperlinks on all of the web part titles using the .unwrap() function (just so that I stay on the page when I click them). Next, I am binding to the click event on those titles (as I did earlier). The new piece is that I am then traversing up and across the DOM to find the table row that contains the web part body, and then I&#8217;m using the .toggle() function to collapse or expand the contents. (I have tested this script in both WSS 3.0 and SharePoint 2010 with a few common List View web parts.)</p>
<p>The .toggle() function figures out whether the selected element is visible or not and switches the visibility. This nets out to each web part expanding or collapsing—based on its current state—when I click its title. This is a nice little trick to gain some screen real estate for the user. Of course, you would probably want to dress it up a little bit with some nice icons and such in a real situation.</p>
<p>This simple script should give you a glimmer what you can start to do with effects. This is the sort of enhancement I often talk about to make the page feel more &#8220;tactile&#8221; for the user. Rather than clicking a setting and waiting for a postback, we can make changes to the page in real time with jQuery; they end up interacting with the page rather than the server.</p>
<p>The following are other useful effect &#8220;families&#8221;:</p>
<p>.hide(), .show(), .toggle(): These three functions simply change the visibility.</p>
<p>.slideUp(), .slideDown(), and .slideToggle(): These functions slide elements up or down and work best with divs.</p>
<p>.fadeOut(), .fadeIn(), and .fadeToggle(): These functions fade elements in or out, basically animating their opacity from 0 to 100 percent, or the reverse.</p>
<p>.animate(): With animate, you can &#8220;move&#8221; CSS properties from one value to another over time. By combining changes to multiple CSS properties into a single animation, you can do things like moving elements around the page, increasing or decreasing them in size, or changing their color or shape.</p>
<h3>Summary</h3>
<p>By attaching your script to events and using effects, you can provide a high level of interactivity for your users. They are used to seeing these sorts of interactions on other commonly used websites, and by using them in SharePoint, you can improve the overall user experience. By carefully using selectors and traversing to locate the right elements in the DOM, you can react to user actions and alter the DOM in real time.</p>
<p>Next up will be the .ajax() function. The .ajax() function is at the core of my <a href="http://spservices.codeplex.com">SPServices jQuery library</a>. Using Ajax, you can request pieces of content from the server during the current page&#8217;s life span. Those pieces can be entire web pages, results from a web service call, or anything you can request over the HTTP protocol.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/articles/a-jquery-primer-for-sharepoint-events-and-effects/feed</wfw:commentRss>
		<slash:comments></slash:comments>
	
		<series:name><![CDATA[A jQuery Primer for SharePoint]]></series:name>
	</item>
		<item>
		<title>Silverlight in SharePoint: The Silverlight Client Object Model</title>
		<link>http://sharepointmagazine.net/articles/silverlight-in-sharepoint-the-silverlight-client-object-model</link>
		<comments>http://sharepointmagazine.net/articles/silverlight-in-sharepoint-the-silverlight-client-object-model#comments</comments>
		<pubDate>Tue, 26 Jul 2011 13:47:38 +0000</pubDate>
		<dc:creator>Karine Bosch</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Featured]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=5810</guid>
		<description><![CDATA[In this third part of the series, I will build a Silverlight application that communicates with SharePoint to render data that is stored within a SharePoint list. The Silverlight app will again be hosted within the out-of-the-box Silverlight web part that comes with SharePoint 2010.]]></description>
			<content:encoded><![CDATA[<p>In this third part of the series, I will build a Silverlight application that communicates with SharePoint to render data that is stored within a SharePoint list. The Silverlight app will again be hosted within the out-of-the-box Silverlight web part that comes with SharePoint 2010.</p>
<p>Through this series of articles we will build a SharePoint demo application that allows members to offer their services and accept another service in return. For example, John likes to garden, but he is lousy in the kitchen. Through the application he can offer his services as a gardener. Hanne likes to cook but needs a hand in the garden. She can accept his offer and cook him a delicious meal. All data will be stored in a SharePoint list called Service Offering.</p>
<p><img class="alignnone size-full wp-image-5884" src="http://sharepointmagazine.net/wp-content/uploads/2011/04/silverlightapp.png" alt="" width="676" height="101" /></p>
<p>In this part of the series we will build a Silverlight application that renders a scrolling banner displaying the services offered that day. Because the offered services are stored in a SharePoint list, they need to be retrieved by the Silverlight application before they can be displayed in the scrolling banner. This can be achieved by using the Silverlight client object model.</p>
<p>You can <a href="http://sharepointmagazine.net/wp-content/uploads/2011/07/Sample2.ServicesBanner.zip" target="_blank">download the complete source code here</a>.</p>
<h2>The Silverlight Banner</h2>
<p> You can create a simple Silverlight 4 application using Visual Studio 2010. If you need a more complex design, you will need tools like Microsoft Expression Blend, but the sample Silverlight application for this article can easily be built in Visual Studio 2010 using the Silverlight Application template.</p>
<p>The Silverlight application consists of a canvas with a panel. For each service offer, a control like the following will be populated with the information about who offers what and which services are desired in return. Some services need to be fulfilled within a certain time frame; therefore, a countdown control will indicate how much time is left. All service controls will be added to the panel and will scroll over the page. If members see an interesting offer, they can check which they want to fulfill.</p>
<p>I&#8217;m not going to dive into the XAML of the Silverlight application, because that is not the subject of this article, but I&#8217;m going to walk you through the code where interaction with SharePoint is needed.</p>
<p>The point of entry of the Silverlight application is the <strong>Application_Startup</strong> method. The <strong>StartupEventArgs</strong> argument contains information on how to initialize the Silverlight application. One of these elements is the <strong>InitParams</strong> dictionary. In this sample we will pass the name of the SharePoint list where all service offerings will be stored. The value will be stored in a static variable that can be consulted from within the different controls that make up the Silverlight application.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">static</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> ListName <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The <strong>Application_Startup </strong>method looks as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> Application_Startup<span style="color: #008000;color: #CCC;color: black;">&#40;</span>
 <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> sender, StartupEventArgs e<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
<span style="color: #008000;color: #CCC;color: black;">&#123;</span>
   <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>e<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">InitParams</span> <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
   <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
       <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>e<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">InitParams</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ContainsKey</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;list&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
         <span style="color: #008000;color: #CCC;color: black;">&amp;</span>amp<span style="color: #008000;color: #CCC;color: black;">;&amp;</span>amp<span style="color: #008000;color: #CCC;color: black;">;</span> <span style="color: #008000;color: #CCC;color: black;">!</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">IsNullOrEmpty</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>e<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">InitParams</span><span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;list&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
       <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
           ListName <span style="color: #008000;color: #CCC;color: black;">=</span>
              e<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">InitParams</span><span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;list&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Replace</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;%20&quot;</span>, <span style="color: #666666;color: #666666;color: maroon;">&quot; &quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
       <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
   <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
  <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">this</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">RootVisual</span> <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> MainPage<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
<span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>The last statement initializes the main user control of the Silverlight application. The XAML of this control is very simple and contains the following elements:</p>
<ul>
<li>A <strong>Canvas</strong>: This is the root control of the user control.</li>
<li>A <strong>Storyboard</strong>: This element is responsible for making the service offerings scroll over the screen from right to left.</li>
<li>A <strong>StackPanel</strong>: This element will be used to add a custom control (as shown in the picture) for each service offering.</li>
<li>A status <strong>border</strong>: This has a start/pause button to start/pause the storyboard.</li>
</ul>
<p>The code-behind of the <strong>MainPage</strong> user control is stored in the <strong>MainPage.xaml.cs</strong> file and populates the ServiceItemPanel stack panel by calling the Silverlight client object model for SharePoint and binding the list item to a separate <strong>ServiceItemControl</strong>, which is displayed here.</p>
<p>picture</p>
<h3>Using the Silverlight Client Object Model</h3>
<p>SharePoint 2010 comes with three different client object models:</p>
<ul>
<li>One for use within .NET applications like a WPF application</li>
<li>One for use from within JavaScript</li>
<li>One for use from within Silverlight applications</li>
</ul>
<p>Before you can start using the Silverlight client object model for SharePoint, you have to reference two assemblies:</p>
<ul>
<li>Microsoft.SharePoint.Client.Silverlight.dll</li>
<li>Microsoft.SharePoint.Client.Silverlight.Runtime.dll</li>
</ul>
<p>Both assemblies are located in the<strong> 14\TEMPLATE\LAYOUTS\ClientBin</strong> folder of the SharePoint root.</p>
<p>Calls to the SharePoint server using the Silverlight client object model  execute asynchronously and on a different thread. Therefore, you first have to capture the current <strong>SynchronizationContext</strong> to make sure you can come back on the UI thread.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> MainPage<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        InitializeComponent<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        ResizeCanvas<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">this</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SizeChanged</span> <span style="color: #008000;color: #CCC;color: black;">+=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> SizeChangedEventHandler<span style="color: #008000;color: #CCC;color: black;">&#40;</span>MainPage_SizeChanged<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        uiThread <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Threading</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SynchronizationContext</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Current</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>uiThread <span style="color: #008000;color: #CCC;color: black;">==</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
           uiThread <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Threading</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SynchronizationContext</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        PopulateBanner<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>The <strong>uiThread</strong> variable is declared as a class-level variable of type <strong>SynchronizationContext</strong>. This class resides in the <strong>System.Threading</strong> namespace:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Threading</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SynchronizationContext</span> uiThread<span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The client context is the starting point for the communication between Silverlight and SharePoint and is located in the <strong>Microsoft.SharePoint.Client</strong> namespace. When you host your Silverlight applications within SharePoint artifacts, you can use <strong>ClientContext.Current</strong>, instead of passing in the URL to the SharePoint site and creating a ClientContext based on that URL. This will be explained later when hosting the Silverlight application within the out-of-the-box Silverlight web part.</p>
<p>The code contains a property for the client context in order to encapsulate code that verifies the existence of a client context.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> ClientContext clientContext<span style="color: #008000;color: #CCC;color: black;">;</span>
<span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> ClientContext ClientCtxt
<span style="color: #008000;color: #CCC;color: black;">&#123;</span>
    get
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>clientContext <span style="color: #008000;color: #CCC;color: black;">==</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            clientContext <span style="color: #008000;color: #CCC;color: black;">=</span> ClientContext<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Current</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>clientContext <span style="color: #008000;color: #CCC;color: black;">==</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">throw</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> Exception<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Connection failed!&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">return</span> clientContext<span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
<span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>The <strong>PopulateBanner</strong> method retrieves the list items from the SharePoint list. Before you can start retrieving list data, you have to load the current web from the client context. Also, the current user is retrieved for later use. The purpose will become clearer later in the article.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">   web <span style="color: #008000;color: #CCC;color: black;">=</span> ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Web</span><span style="color: #008000;color: #CCC;color: black;">;</span>
   ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Load</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>web<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
   currentUser <span style="color: #008000;color: #CCC;color: black;">=</span> ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Web</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">CurrentUser</span><span style="color: #008000;color: #CCC;color: black;">;</span>
   ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Load</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>currentUser<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>Once the web is loaded, the list is retrieved using the <strong>GetByTitle</strong> method of the client object model using the list name passed in when the Silverlight application is initialized. This list contains all services offered by members of the site. The <strong>GetByTitle</strong> method is available on the <strong>Lists</strong> collection of the <strong>Web</strong> object of the current client context.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">   serviceList <span style="color: #008000;color: #CCC;color: black;">=</span> ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Web</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Lists</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">GetByTitle</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>App<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ListName</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The list items are retrieved by means of a <strong>CamlQuery</strong> object. The <strong>ViewXml</strong> property can be used to specify a sort order and/or a filter criteria. In this sample only, the list items with a start date before today and no expiration date or an expiration date after today are retrieved. </p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;color: #FCFFBA;color: black;">     camlQuery.ViewXml = &quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;View<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Query<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;OrderBy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'PublishDate'</span> <span style="color: #000066;">Ascending</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'False'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>&quot;
                + &quot;   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'Title'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>&quot;
                + &quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/OrderBy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Where<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;And<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Leq<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'ServicePublishDate'</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>&quot;
                + &quot;         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Value</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'DateTime'</span> <span style="color: #000066;">IncludeTimeValue</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'FALSE'</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Today</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Leq<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Or<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Geq<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'ServiceExpirationDate'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>&quot;
                + &quot;          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Value</span> <span style="color: #000066;">Type</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'DateTime'</span> <span style="color: #000066;">IncludeTimeValue</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'FALSE'</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Today</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Geq<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;IsNull<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;FieldRef</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">'ServiceExpirationDate'</span> <span style="color: #000000; font-weight: bold;">/&gt;</span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/IsNull<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Or<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/And<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Where<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
                + &quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Query<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/View<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;;</pre></div></div>

<p>The <strong>GetItems</strong> method is then executed using the <strong>CamlQuery</strong> object. The returned object is of type <strong>ListItemCollection</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">   listItems <span style="color: #008000;color: #CCC;color: black;">=</span> newsList<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">GetItems</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>camlQuery<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>To actually retrieve the list items, you have to execute the <strong>Load</strong> method on the client context. Together with the <strong>Load</strong> method, you have to specify which columns of the list items you want to see returned. This allows you to limit the columns returned over the wire. In this sample, columns like the title, the short description, the publish date, the expiration date, and so on, are retrieved because these are the columns that will be displayed within the service item control.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">     ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Load</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>listItems,
           items <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> items<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Include</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Title&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServiceShortDescription&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServicePublishDate&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServiceExpirationDate&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServicesInReturn&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Author&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServiceTaker&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>,
                item <span style="color: #008000;color: #CCC;color: black;">=&gt;</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;SelectedService&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span>
     <span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The <strong>ExecuteQueryAsync</strong> method of the client context is responsible for starting the call to the server. Because this method runs asynchronously, you have to specify two methods on which the call can come back when it returns from the server: one method for when the call returns successfully and another method for when the call to the server fails.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">     ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ExecuteQueryAsync</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>HandleClientRequestSucceeded, HandleClientRequestFailed<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The <strong>HandleClientRequestFailed</strong> method will be executed when the call to the server fails. The <strong>EventArgs</strong> argument contains an error message that is temporarily stored in a private string message. Then the <strong>Post</strong> method on the main UI thread is called to redirect the request to the <strong>OperationFailed</strong> method on the main UI thread. There a message box will be displayed rendering the error message.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> errorMessage<span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> HandleClientRequestFailed<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> sender, ClientRequestFailedEventArgs e<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        errorMessage <span style="color: #008000;color: #CCC;color: black;">=</span> e<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Message</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        uiThread<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Post</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #8FB394;color: blue;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Threading</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SendOrPostCallback</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">delegate</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> state<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
            EventHandler h <span style="color: #008000;color: #CCC;color: black;">=</span> OperationFailed<span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>h <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                h<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">this</span>, EventArgs<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Empty</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#125;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> OperationFailed<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> sender, EventArgs e<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        MessageBox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Show</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Format</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Failure! /n{0}&quot;</span>, errorMessage<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>The <strong>HandleClientRequestSucceeded</strong> method will be executed when the call to the server returns successfully. Also, here the <strong>Post</strong> method on the main UI thread is used to redirect the request back to the main UI thread. The <strong>OperationSucceeded</strong> method is called to handle the result:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> HandleClientRequestSucceeded<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> sender, ClientRequestSucceededEventArgs e<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        uiThread<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Post</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #8FB394;color: blue;">new</span> <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Threading</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SendOrPostCallback</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">delegate</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> state<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
            EventHandler h <span style="color: #008000;color: #CCC;color: black;">=</span> OperationSucceeded<span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>h <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                h<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">this</span>, EventArgs<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Empty</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#125;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>The <strong>OperationSucceeded</strong> method calls the <strong>BuildBanner</strong> method, which loops through the list items collection returned by the server.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> OperationSucceeded<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> sender, EventArgs e<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        BuildBanner<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<h3>The BuildBanner Method</h3>
<p>The <strong>BuildBanner</strong> method loops through the list items collection, which got populated by executing the <strong>ExecuteQueryAsync</strong> method of the client context. For each list item in this collection, a Silverlight user control is instantiated, setting its <strong>DataContext</strong> property to the list item.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> BuildBanner<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
<span style="color: #008000;color: #CCC;color: black;">&#123;</span>
   <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// Load the services banner          </span>
   <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">foreach</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>ListItem item <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">in</span> listItems<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
   <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
       ServiceItemControl itemControl <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> ServiceItemControl<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
       itemControl<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">DataContext</span> <span style="color: #008000;color: #CCC;color: black;">=</span> item<span style="color: #008000;color: #CCC;color: black;">;</span>
       <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// the other code comes hereafter</span>
   <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
<span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>Data like <strong>ServicesInReturn</strong> is passed to the item control through a property. This is because the data is stored as a #;-separated string and some extra code needs to be executed before it can be rendered as check boxes.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">       <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// pass the services in return</span>
       <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServicesInReturn&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
          itemControl<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ServicesInReturn</span> <span style="color: #008000;color: #CCC;color: black;">=</span> GetServicesInReturn<span style="color: #008000;color: #CCC;color: black;">&#40;</span>item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServicesInReturn&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ToString</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The <strong>ExpirationDate</strong> is also passed through a property because it needs to be passed to the countdown control on the item control. We also pass an empty expiration date because in that case the countdown control will not be displayed.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">       <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// pass the expiration date</span>
       DateTime<span style="color: #008000;color: #CCC;color: black;">?</span> expirationDateTime <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">;</span>
       <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServiceExpirationDate&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
          expirationDateTime <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #000000;">System</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Convert</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ToDateTime</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServiceExpirationDate&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
       itemControl<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ExpirationDateTime</span> <span style="color: #008000;color: #CCC;color: black;">=</span> expirationDateTime<span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>The username of the current user is also passed through a property. When the services offered scroll over the screen, the current user can select one of the services asked for in return. At that time, the SharePoint list item that corresponds with the item control will be updated with the name of the current user and the selected service in return.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">       <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// pass the name of the current user</span>
       itemControl<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">UserName</span> <span style="color: #008000;color: #CCC;color: black;">=</span> currentUser<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">LoginName</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>When the service is already honored by a user, the selected service in return is passed through a property, and the corresponding check box will be checked.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">       <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;SelectedService&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
           itemControl<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">SelectedService</span> <span style="color: #008000;color: #CCC;color: black;">=</span> item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;SelectedService&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ToString</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>A custom event handler is added to the item control. When a user decides to accept a service and offer a service in return, this choice should be stored in SharePoint. I could have passed the client context to the item control, but I prefer to raise an event and handle all SharePoint communication from within <strong>MainPage.xaml.cs</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">       itemControl<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ServiceSelected</span> <span style="color: #008000;color: #CCC;color: black;">+=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> ServiceSelectedHandler<span style="color: #008000;color: #CCC;color: black;">&#40;</span>itemControl_ServiceSelected<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>Then the control is added to the <strong>ServiceItemPanel</strong> stack panel control of the Silverlight application.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">       ServiceItemPanel<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Children</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Add</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>itemControl<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span></pre></div></div>

<p>When all service item controls are created, the size of the stack panel and the status borders need to be recalculated based on the width of one single service item control and the number of list items. The <strong>To</strong> and <strong>From</strong> properties of a <strong>DoubleAnimation</strong> storyboard indicate from where to where a certain control is moved. To avoid that the banner scrolls as fast as light when a lot of  services are offered,  the duration of the <strong>DoubleAnimation</strong> is recalculated.  Then the storyboard is started.</p>
<h3>The ServiceItemControl</h3>
<p>The <strong>ServiceItemControl</strong> is a Silverlight user control and looks like the following:</p>
<p><img class="alignnone size-full wp-image-5885" src="http://sharepointmagazine.net/wp-content/uploads/2011/04/ServiceItemControl.png" alt="" width="298" height="135" /></p>
<p>The <strong>DataContext</strong> property of this user control is used for data binding purposes. As explained in the previous section, when an instance of this control is created, a SharePoint list item is passed to this property. The properties of the incoming list item are data bound in XAML. Strings and other primitive data types can easily be bound to Silverlight controls. For example, the service offered, which is stored in the <strong>Title</strong> property of a list item, is data bound as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;TextBlock</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;TitleTextBlock&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;3,0,0,0&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">Foreground</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Yellow&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">FontFamily</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Comic Sans MS&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">FontSize</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;14&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">Text</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;{Binding [Title]}&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">TextAlignment</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Left&quot;</span> <span style="color: #000066;">Width</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;160&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>But some properties have a more complex data type like, for example a user. In that case, we need to define a data-binding expression. The following code snippet shows the <strong>TextBlock</strong> that is used to bind the username of the demander by using a <strong>ListItemConverter</strong>. The <strong>ConverterParameter</strong> defines to which list item property you want to bind:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;TextBlock</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;DemanderTextBlock&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">Foreground</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Yellow&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">FontFamily</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Comic Sans MS&quot;</span> </span>
<span style="color: #009900;">           <span style="color: #000066;">FontSize</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;14&quot;</span></span>
<span style="color: #009900;">           <span style="color: #000066;">Text</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;{Binding Converter={StaticResource listItemConverter}, ConverterParameter='Author'}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>The <strong>ListItemConverter</strong> is a class that inherits from <strong>IValueConverter</strong>. The <strong>Convert</strong> method accepts the value, the data type, and the name of the column. If the column is of type <strong>Text</strong> or <strong>Number</strong>, the value will be returned without conversion. If the incoming data is of type user, then the incoming value is cast to the type <strong>FieldUserValue.</strong> The <strong>LookupValue</strong> property contains the username and is returned for display. If the incoming column is of type <strong>URL</strong>, then the incoming value is cast to the type <strong>FieldUrlValue</strong>, and the <strong>Url</strong> property is returned for display.</p>
<p>The <strong>ListItemConverter</strong> class in this sample does not convert all types of columns and contains only the conversions necessary in this sample. It looks as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">class</span> ListItemConverter <span style="color: #008000;color: #CCC;color: black;">:</span> IValueConverter
    <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> Convert<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> value, Type targetType, <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> parameter, <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Globalization</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">CultureInfo</span> culture<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
            <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// get the list item's field to be displayed</span>
            <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> fieldToDisplay <span style="color: #008000;color: #CCC;color: black;">=</span> parameter <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">as</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">IsNullOrEmpty</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                fieldToDisplay <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #666666;color: #666666;color: maroon;">&quot;Title&quot;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            ListItem sourceListItem <span style="color: #008000;color: #CCC;color: black;">=</span> value <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">as</span> ListItem<span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>sourceListItem <span style="color: #008000;color: #CCC;color: black;">==</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">throw</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> ArgumentException<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;value&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">StartsWith</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Lookup.&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> lookupFieldName <span style="color: #008000;color: #CCC;color: black;">=</span> fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Replace</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Lookup.&quot;</span>, <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Empty</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                FieldLookupValue lookupValue <span style="color: #008000;color: #CCC;color: black;">=</span> sourceListItem<span style="color: #008000;color: #CCC;color: black;">&#91;</span>lookupFieldName<span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">as</span> FieldLookupValue<span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>lookupValue <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">return</span> lookupValue<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">LookupValue</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">else</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">throw</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> ArgumentException<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Invalid lookup field.&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">else</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>sourceListItem<span style="color: #008000;color: #CCC;color: black;">&#91;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #8FB394;color: blue;">is</span> FieldUrlValue<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                FieldUrlValue urlValue <span style="color: #008000;color: #CCC;color: black;">=</span> sourceListItem<span style="color: #008000;color: #CCC;color: black;">&#91;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">as</span> FieldUrlValue<span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>urlValue <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">return</span> urlValue<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Url</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">else</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">throw</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> ArgumentNullException<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Invalid URL field.&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">else</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>sourceListItem<span style="color: #008000;color: #CCC;color: black;">&#91;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #8FB394;color: blue;">is</span> FieldUserValue<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                FieldUserValue userValue <span style="color: #008000;color: #CCC;color: black;">=</span> sourceListItem<span style="color: #008000;color: #CCC;color: black;">&#91;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">as</span> FieldUserValue<span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>userValue <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">return</span> userValue<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">LookupValue</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">else</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">throw</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> ArgumentNullException<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Invalid User field.&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">else</span>
            <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// return what's being asked for</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">return</span> sourceListItem<span style="color: #008000;color: #CCC;color: black;">&#91;</span>fieldToDisplay<span style="color: #008000;color: #CCC;color: black;">&#93;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> ConvertBack<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> value, Type targetType, <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> parameter, <span style="color: #000000;">System.<span style="color: #0000FF;color: black;">Globalization</span></span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">CultureInfo</span> culture<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">throw</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> NotImplementedException<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span> <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
    <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>To be able to use the <strong>ListItemConverter</strong> from within Silverlight user controls, you have to add an extra element to the <strong>Resources</strong> element of the user control:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;UserControl.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;local:ListItemConverter</span> <span style="color: #000066;">x:Key</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;listItemConverter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/UserControl.Resources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>As a side node, in Silverlight 3 you had to add all SharePoint data types, but since Silverlight 4 you can data bind list item properties using square brackets.</p>
<p>The code behind the <strong>ServiceItemControls</strong> defines a delegate and an event handler that is raised when a user selects one of the checkboxes populated with the services wanted in return.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">delegate</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> ServiceSelectedHandler<span style="color: #008000;color: #CCC;color: black;">&#40;</span>ListItem item, <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> service<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
<span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">partial</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">class</span> ServiceItemControl <span style="color: #008000;color: #CCC;color: black;">:</span> UserControl
<span style="color: #008000;color: #CCC;color: black;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">event</span> ServiceSelectedHandler ServiceSelected<span style="color: #008000;color: #CCC;color: black;">;</span>
    <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// rest of the code omitted for brevity</span>
    …
<span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>Some list item properties cannot be data bound using the list item converter. They are handled in the code-behind. For example, the <strong>ServicesInReturn</strong> property contains a semicolon-separated string and needs to be rendered as a list of checkboxes. The <strong>PopulateCheckBoxPanel</strong> method creates a checkbox for each string in the list of services. Each <strong>CheckBox</strong> has a <strong>TextBox</strong> with its <strong>Text</strong> property set to the service. To each checkbox the custom event handler is added.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> PopulateCheckBoxPanel<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
            ReturnStackPanel<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Children</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Clear</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">if</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>servicesInReturn <span style="color: #008000;color: #CCC;color: black;">!=</span> <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">null</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">foreach</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> service <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">in</span> servicesInReturn<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
                <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                    CheckBox chkbox <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> CheckBox<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    chkbox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Foreground</span> <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> SolidColorBrush<span style="color: #008000;color: #CCC;color: black;">&#40;</span>Colors<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">White</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    chkbox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">FontFamily</span> <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> FontFamily<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;Comic Sans MS&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    chkbox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">FontSize</span> <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #FF0000;color: #DDD;color: maroon;">12.0</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    chkbox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Width</span> <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #FF0000;color: #DDD;color: maroon;">220.0</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// use a textblock to be able to wrap the text</span>
                    <span style="color: #008080; font-style: italic;color: #CDC;color: green;">//chkbox.Content = s;</span>
                    TextBlock textblock <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> TextBlock<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    textblock<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Text</span> <span style="color: #008000;color: #CCC;color: black;">=</span> service<span style="color: #008000;color: #CCC;color: black;">;</span>
                    textblock<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Width</span> <span style="color: #008000;color: #CCC;color: black;">=</span> <span style="color: #FF0000;color: #DDD;color: maroon;">195.0</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    textblock<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">TextWrapping</span> <span style="color: #008000;color: #CCC;color: black;">=</span> TextWrapping<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Wrap</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    chkbox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Content</span> <span style="color: #008000;color: #CCC;color: black;">=</span> textblock<span style="color: #008000;color: #CCC;color: black;">;</span>
                    chkbox<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #008000;color: #8FB394;color: blue;">Checked</span> <span style="color: #008000;color: #CCC;color: black;">+=</span> <span style="color: #008000;color: #8FB394;color: blue;">new</span> RoutedEventHandler<span style="color: #008000;color: #CCC;color: black;">&#40;</span>checkbox_Checked<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    ReturnStackPanel<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Children</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Add</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>chkbox<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>I could have done this differently by creating a list box with a data template containing a checkbox. In that case I would have been able to bind the list of services to the list box using the <strong>ItemsSource</strong> property.</p>
<p>The <strong>ExpirationDateTime</strong> property handles the countdown control. If there is no expiration date, the control is hidden.  When a service is already offered in return, the <strong>SetSelectedService</strong> method displays a “Served!” label over the list of checkboxes. When a service offer is not yet honored, a user can click one of the services offered in return, which fires the event handler <strong>checkbox_Checked</strong> to place the label “Served!” over the checkboxes. This label is wrapped in its own Silverlight user control. </p>
<p><a href="http://sharepointmagazine.net/wp-content/uploads/2011/05/served.png"><img class="alignnone size-full wp-image-6174" src="http://sharepointmagazine.net/wp-content/uploads/2011/05/served.png" alt="ServedControl" width="84" height="33" /></a></p>
<p>The label is moved smoothly over the list of services using a storyboard. The event handler also raises another custom event: the <strong>ServiceSelected</strong> event. It returns the impacted list item and the selected service. This <strong>ServiceSelected</strong> event is caught by the <strong>MainPage</strong> user control, which will save the information to SharePoint. Also, the update executes asynchronously and on a different thread.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">private</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> itemControl_ServiceSelected<span style="color: #008000;color: #CCC;color: black;">&#40;</span>ListItem item, <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">string</span> service<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
            <span style="color: #008080; font-style: italic;color: #CDC;color: green;">// Save to SharePoint</span>
            item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;SelectedService&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #CCC;color: black;">=</span> service<span style="color: #008000;color: #CCC;color: black;">;</span>
            item<span style="color: #008000;color: #CCC;color: black;">&#91;</span><span style="color: #666666;color: #666666;color: maroon;">&quot;ServiceTaker&quot;</span><span style="color: #008000;color: #CCC;color: black;">&#93;</span> <span style="color: #008000;color: #CCC;color: black;">=</span> ClientCtxt<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Web</span><span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">CurrentUser</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            item<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">Update</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            serverAction <span style="color: #008000;color: #CCC;color: black;">=</span> ServerAction<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">UpdateService</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            clientContext<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">ExecuteQueryAsync</span><span style="color: #008000;color: #CCC;color: black;">&#40;</span>HandleClientRequestSucceeded, HandleClientRequestFailed<span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>In this sample, the <strong>ExecuteQueryAsync</strong> method points to the same success and failed handlers. Therefore, I added an enumeration to the code indicating which server action is taking place. In the <strong>HandleClientRequestSucceeded</strong> event handler, I test upon the value of this enum variable to decide what to do. Only when the services are retrieved on initialization of the Silverlight application is the scrolling banner built up.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;color: #FCFFBA;color: black;">        <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">public</span> <span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">void</span> OperationSucceeded<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #6666cc; font-weight: bold;color: #343832;color: blue;">object</span> sender, EventArgs e<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">switch</span> <span style="color: #008000;color: #CCC;color: black;">&#40;</span>serverAction<span style="color: #008000;color: #CCC;color: black;">&#41;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">case</span> ServerAction<span style="color: #008000;color: #CCC;color: black;">.</span><span style="color: #0000FF;color: black;">RetrieveServices</span><span style="color: #008000;color: #CCC;color: black;">:</span>
                    BuildBanner<span style="color: #008000;color: #CCC;color: black;">&#40;</span><span style="color: #008000;color: #CCC;color: black;">&#41;</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">break</span><span style="color: #008000;color: #CCC;color: black;">;</span>
                <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">default</span><span style="color: #008000;color: #CCC;color: black;">:</span>
                    <span style="color: #0600FF; font-weight: bold;color: #B83A24;color: blue;">break</span><span style="color: #008000;color: #CCC;color: black;">;</span>
            <span style="color: #008000;color: #CCC;color: black;">&#125;</span>
        <span style="color: #008000;color: #CCC;color: black;">&#125;</span></pre></div></div>

<p>That&#8217;s it for the code in the Silverlight application. The compiled Silverlight application is a file with the extension <strong>.xap</strong>. It is in fact a package, which you can rename with the .zip extension and take a look at what&#8217;s inside. You’ll see that both assemblies for the Silverlight client object model are packaged within the<strong> .xap</strong> file. The Silverlight application also contains an assembly containing the compiled code.</p>
<p><img class="alignnone size-full wp-image-5886" src="http://sharepointmagazine.net/wp-content/uploads/2011/04/xap-content.png" alt="" width="615" height="114" /></p>
<p>When extracting the <strong>AppManifest.xaml</strong> file from the package, you’ll notice the entry point is App.xaml. It also contains a list of all assemblies that make up the Silverlight application.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;color: #FCFFBA;color: black;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Deployment</span></span>
<span style="color: #009900;">   <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;&lt;a href=&quot;</span>http://schemas.microsoft.com/client/2007/deployment<span style="color: #ff0000;color: #666666;color: maroon;">&quot;&gt;</span></span>http://schemas.microsoft.com/client/2007/deployment<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
   xmlns:x=&quot;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>http://schemas.microsoft.com/winfx/2006/xaml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>&quot;
   EntryPointAssembly=&quot;Sample1.ServicesBanner&quot;
   EntryPointType=&quot;ServicesBanner.App&quot;
   RuntimeVersion=&quot;4.0.50401.0&quot;&gt;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;Deployment.Parts<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;AssemblyPart</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Sample1.ServicesBanner&quot;</span> <span style="color: #000066;">Source</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Sample1.ServicesBanner.dll&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;AssemblyPart</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Microsoft.SharePoint.Client.Silverlight&quot;</span> <span style="color: #000066;">Source</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Microsoft.SharePoint.Client.Silverlight.dll&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;AssemblyPart</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Microsoft.SharePoint.Client.Silverlight.Runtime&quot;</span> <span style="color: #000066;">Source</span>=<span style="color: #ff0000;color: #666666;color: maroon;">&quot;Microsoft.SharePoint.Client.Silverlight.Runtime.dll&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Deployment.Parts<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;color: blue;color: black;">&lt;/Deployment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now it is time to deploy the Silverlight application to SharePoint. I upload the Silverlight application to the XAPS document library. I place a Silverlight web part on a web part page and specify the path to the Silverlight application.</p>
<p>In the editor part of the web part, you have to enter the <strong>initParams</strong> string requested by your Silverlight application. In this sample, that means passing the name of the list where the service offerings are stored.</p>
<p><img class="alignnone size-full wp-image-5888" src="http://sharepointmagazine.net/wp-content/uploads/2011/04/SL-editor-part1.png" alt="" width="206" height="128" /></p>
<p>Once the initialization parameters, you can click the <strong>OK</strong> button of the web part. The Silverlight application will  be rendered on the page.</p>
<p><img class="alignnone size-full wp-image-5890" src="http://sharepointmagazine.net/wp-content/uploads/2011/04/ServicesBanner1.png" alt="Services banner" width="663" height="208" /></p>
<h2>Conclusion</h2>
<p>In this article, I explained how to use the Silverlight client object model to retrieve and update data stored in SharePoint. The Silverlight application is hosted in the out-of-the-box Silverlight web part. In the next article, I will explain how you can build your own Silverlight web part using the Visual Web Part item template available in Visual Studio 2010.</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/articles/silverlight-in-sharepoint-the-silverlight-client-object-model/feed</wfw:commentRss>
		<slash:comments></slash:comments>
	
		<series:name><![CDATA[Silverlight in SharePoint]]></series:name>
	</item>
		<item>
		<title>Letter from the Editor #4 &#8211; Vacation</title>
		<link>http://sharepointmagazine.net/blog/letter-from-the-editor-4-vacation</link>
		<comments>http://sharepointmagazine.net/blog/letter-from-the-editor-4-vacation#comments</comments>
		<pubDate>Mon, 18 Jul 2011 17:39:08 +0000</pubDate>
		<dc:creator>Bjørn Furuknap</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Letters from the Editor]]></category>

		<guid isPermaLink="false">http://sharepointmagazine.net/?p=6439</guid>
		<description><![CDATA[No, we haven’t gone silent, but we’ve had some plans rearranged. Now we’re back, though, and as you probably know by now, we have some news of the interesting type for you. SharePoint Magazine Issue 3 Cut-Off Date First of all, because this is of some urgency, the cut-off date for getting issue 3 of [...]]]></description>
			<content:encoded><![CDATA[<p>No, we haven’t gone silent, but we’ve had some plans rearranged. Now we’re back, though, and as you probably know by now, we have some news of the interesting type for you. <img src='http://sharepointmagazine.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h1>SharePoint Magazine Issue 3 Cut-Off Date</h1>
<p>First of all, because this is of some urgency, the cut-off date for getting issue 3 of SharePoint Magazine print is on <strong>Wednesday, July 20</strong>. That means that if you want to get print issue 3 as part of your subscription, you need to sign up before then.</p>
<p><strong>Sign up here: <a href="http://spm.to/sub">http://spm.to/sub</a>.</strong></p>
<p>Of course, even if you miss that date (or you read this after the cut-off date has passed), you can get single issues shipped now. You can see all of our purchase option on our new <a href="http://sharepointmagazine.net/purchase">Purchase page</a>.</p>
<p>Oh, and that means that just after July 20, we’ll start shipping issue 3. I know, I know, it’s been two months since the previous issue, but it was always the plan to have a one-month break during the summer. We had planned to have that in July, but as mentioned, some last-minute change of plans made June that break-month.</p>
<h1>Aspiring Authors Competition Results</h1>
<p>In May this year, we ran a competition called Aspiring Authors Competition, in which we invited some very skilled authors to submit their articles for evaluation and judgment by the SharePoint community. And you did, so I’m happy now to present the results of the competition.</p>
<p>The finalists all get both publishing contracts with SharePoint Magazine as well as a scholarship at <a href="http://uspja.com/">USPJ Academy</a>. The winner gets a longer contract and scholarship and in addition inclusion in an upcoming author mentoring program that USPJA Publishing will run.</p>
<p>Well, I’m guessing it’s time to announce the results.</p>
<p>In order, from least to most votes, they are as follows:</p>
<ul>
<li>Josh McCarty’s “Best Practices for SharePoint Groups” (third place, 51 votes)</li>
<li>Mikael Svenson’s “Three Main Reasons Why You Should Upgrade to FAST for SharePoint” (runner-up, 112 votes)</li>
<li><strong>Andrew Vevers’ “A Guide to Leaving Lotus Notes and Moving to Microsoft SharePoint” (winner, 125 votes)</strong></li>
</ul>
<p>Congratulations to Andrew Vevers as our Aspiring Author Competition winner for 2011 and thanks to you, the community, for helping us decide the winner.</p>
<h1>New Column: <a href="http://sharepointmagazine.net/leading-change">Leading Change with Kerri Abraham</a></h1>
<p><img class="alignright" title="Kerri-Abraham" src="http://sharepointmagazine.net/wp-content/uploads/2011/07/Kerri-Abraham-Headshot-263x300.jpg" alt="Kerri Abraham" width="158" height="180" /></p>
<p>We’re also proud to announce that we have a new resident author on the team. User adoption expert Kerri Abraham joins us to write in a new column called Leading Change, where she discusses the strategies, tools, and methods she has used to create her amazing results in user adoption.</p>
<p align="left">Kerri will be adding additional posts in her column on a regular basis, starting with her already published article that also gives name to the column, namely, Leading Change.</p>
<p>However, I know Kerri to be a person of strong convictions, so I’m sure that she’ll contribute far more than just her tasked user adoption content, and I’m sure she appreciates topic suggestions in the comments too.</p>
<p>Check out <a href="http://sharepointmagazine.net/leading-change">Leading Change with Kerri Abraham</a>.</p>
<h1>New Commenting System</h1>
<p>Speaking of comments, you may notice that we’ve moved away from the forum-based commenting system to Facebook comments. Frankly, the forum commenting system didn’t work as we had hoped. Now, commenting is much quicker, and you have an easy option to post the comment to your Facebook wall too, to drive even more comments and keep the conversations going. If you’re not on Facebook, you can sign in using Hotmail, AOL, or Yahoo too.</p>
<p><em>I happen to know that Kerri is particularly fond of the new commenting system, and I’ll take her silence as agreement. <img src='http://sharepointmagazine.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </em></p>
<p>&nbsp;</p>
<p>That’s actually it for this update. I hope you won’t let the new commenting system sit there all by itself but instead comment and let us know your thoughts.</p>
<p>And by all means, keep watching this space for more updates now that summer is if not over then at least well underway.</p>
<p>.b</p>
]]></content:encoded>
			<wfw:commentRss>http://sharepointmagazine.net/blog/letter-from-the-editor-4-vacation/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>

