<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Silverlight for Windows Phone Performance team blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/slmperf/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/slmperf/feed.xml</link>
    <description>This blog has been created by members of Silverlight for Windows Phone Performance team to convey best practices, tips and tricks for common performance issues on the phone. We&amp;#039;ll discuss common pitfalls, platform bugs and any other issues we find</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:27:28 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Windows Phone Mango change, Listbox: How to detect compression(end of scroll) states ?</title>
      <link>https://docs.microsoft.com/archive/blogs/slmperf/windows-phone-mango-change-listbox-how-to-detect-compressionend-of-scroll-states</link>
      <pubDate>Thu, 30 Jun 2011 20:19:00 GMT</pubDate>
      <dc:creator><![CDATA[SLMPerf]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/slmperf/2011/06/30/windows-phone-mango-change-listbox-how-to-detect-compressionend-of-scroll-states/</guid>
      <description><![CDATA[[Update: This is available after Beta2(Trial) build. Wait for RC/RTM builds]  If you’ve ever used a...]]></description>
      <content:encoded><![CDATA[<p>[<em>Update</em>: This is available after Beta2(Trial) build. Wait for RC/RTM builds]</p>  <p>If you’ve ever used a ListBox or ScrollViewer control and wanted to implement “infinite scrolling”, great news: in Mango you can easily detect both the end of scroll and compression states. </p>  <p>Infinite scrolling is a nice concept used when the data for a Listbox control is fetched from a server. Many web services let you fetch the data in chunks by specifying a starting location and number of records to retrieve in order to implement paging</p>  <p>A lot of web services are designed for a client to fetch ~40 items. Then, as the end user scrolls to the bottom of the list, client code detects that the end of the scrolling region has been reached (when the list compresses), and then fetches the next 40 odd items from the server.</p>  <p>Obviousy it isn’t a true infinite scrolling list – memory concerns can prop up, but it’ll feel infinite to most users if you implement a reasonable maximum.</p>  <h4>How to detect the end of scrolling</h4>  <p>On Windows Phone 7.0, the developer community came up with a bunch of hacks that worked in some situations, but we wanted to really offer this functionality in the platform for Mango and feel that it’s a much cleaner implementation as a result. Less hacking required!</p>  <p>So in Mango, throw away your old code – we’ve made this very easy and 100% reliable!</p>  <p>The attached sample shows all the various events that can be hooked to when scrolling on a WP7.1 application.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/metablogapi/5810.image_4759BCBA.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80-metablogapi/5810.image_5F00_4759BCBA.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/metablogapi/8546.image_thumb_4E0CC63D.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80-metablogapi/8546.image_5F00_thumb_5F00_4E0CC63D.png" width="202" height="377" /></a></p>  <p>We addressed this problem by introducing two new VisualStateGroups: <b>HorizontalCompression</b> and <b>VerticalCompression</b>.</p>  <p>The default style for the ScrollViewer does not include these new visual states – if you’re using them in your app, make sure to add a style to the app’s resources to expose these new VisualStateGroups.</p>  <p>Here’s the style:</p>  <p>&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">Style </span><span style="color: red">TargetType</span><span style="color: blue">=&quot;ScrollViewer&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;VerticalScrollBarVisibility&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;Auto&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;HorizontalScrollBarVisibility&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;Auto&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;Background&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;Transparent&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;Padding&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;0&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;BorderThickness&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;0&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;BorderBrush&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;Transparent&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter </span><span style="color: red">Property</span><span style="color: blue">=&quot;Template&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Setter.Value</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">ControlTemplate </span><span style="color: red">TargetType</span><span style="color: blue">=&quot;ScrollViewer&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Border </span><span style="color: red">BorderBrush</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">BorderBrush</span><span style="color: blue">}&quot; </span><span style="color: red">BorderThickness</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">BorderThickness</span><span style="color: blue">}&quot;      <br /></span><span style="color: blue"></span><span style="color: red">Background</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">Background</span><span style="color: blue">}&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualStateManager.VisualStateGroups</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualStateGroup </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;ScrollStates&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualStateGroup.Transitions</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualTransition </span><span style="color: red">GeneratedDuration</span><span style="color: blue">=&quot;00:00:00.5&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateGroup.Transitions</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;Scrolling&quot;&gt; &lt;</span><span style="color: #a31515">Storyboard</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">DoubleAnimation </span><span style="color: red">Storyboard.TargetName</span><span style="color: blue">=&quot;VerticalScrollBar&quot;      <br /></span><span style="color: red">Storyboard.TargetProperty</span><span style="color: blue">=&quot;Opacity&quot; </span><span style="color: red">To</span><span style="color: blue">=&quot;1&quot; </span><span style="color: red">Duration</span><span style="color: blue">=&quot;0&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">DoubleAnimation </span><span style="color: red">Storyboard.TargetName</span><span style="color: blue">=&quot;HorizontalScrollBar&quot;      <br /></span><span style="color: red">Storyboard.TargetProperty</span><span style="color: blue">=&quot;Opacity&quot; </span><span style="color: red">To</span><span style="color: blue">=&quot;1&quot; </span><span style="color: red">Duration</span><span style="color: blue">=&quot;0&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">Storyboard</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualState</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;NotScrolling&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualState</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateGroup</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualStateGroup </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;VerticalCompression&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;NoVerticalCompression&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionTop&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionBottom&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateGroup</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualStateGroup </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;HorizontalCompression&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;NoHorizontalCompression&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionLeft&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionRight&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateGroup</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateManager.VisualStateGroups</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">Grid </span><span style="color: red">Margin</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">Padding</span><span style="color: blue">}&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">ScrollContentPresenter </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;ScrollContentPresenter&quot; </span><span style="color: red">Content</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">Content</span><span style="color: blue">}&quot;      <br /></span><span style="color: red">ContentTemplate</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ContentTemplate</span><span style="color: blue">}&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">ScrollBar </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;VerticalScrollBar&quot; </span><span style="color: red">IsHitTestVisible</span><span style="color: blue">=&quot;False&quot; </span><span style="color: red">Height</span><span style="color: blue">=&quot;Auto&quot; </span><span style="color: red">Width</span><span style="color: blue">=&quot;5&quot;      <br /></span><span style="color: red">HorizontalAlignment</span><span style="color: blue">=&quot;Right&quot; </span><span style="color: red">VerticalAlignment</span><span style="color: blue">=&quot;Stretch&quot; </span><span style="color: red">Visibility</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ComputedVerticalScrollBarVisibility</span><span style="color: blue">}&quot;      <br /></span><span style="color: red">IsTabStop</span><span style="color: blue">=&quot;False&quot; </span><span style="color: red">Maximum</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ScrollableHeight</span><span style="color: blue">}&quot; </span><span style="color: red">Minimum</span><span style="color: blue">=&quot;0&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">VerticalOffset</span><span style="color: blue">}&quot;      <br /></span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Vertical&quot; </span><span style="color: red">ViewportSize</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ViewportHeight</span><span style="color: blue">}&quot; /&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">ScrollBar </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;HorizontalScrollBar&quot; </span><span style="color: red">IsHitTestVisible</span><span style="color: blue">=&quot;False&quot; </span><span style="color: red">Width</span><span style="color: blue">=&quot;Auto&quot; </span><span style="color: red">Height</span><span style="color: blue">=&quot;5&quot;      <br /></span><span style="color: red">HorizontalAlignment</span><span style="color: blue">=&quot;Stretch&quot; </span><span style="color: red">VerticalAlignment</span><span style="color: blue">=&quot;Bottom&quot; </span><span style="color: red">Visibility</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ComputedHorizontalScrollBarVisibility</span><span style="color: blue">}&quot;      <br /></span><span style="color: red">IsTabStop</span><span style="color: blue">=&quot;False&quot; </span><span style="color: red">Maximum</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ScrollableWidth</span><span style="color: blue">}&quot; </span><span style="color: red">Minimum</span><span style="color: blue">=&quot;0&quot; </span><span style="color: red">Value</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">HorizontalOffset</span><span style="color: blue">}&quot;      <br /></span><span style="color: red">Orientation</span><span style="color: blue">=&quot;Horizontal&quot; </span><span style="color: red">ViewportSize</span><span style="color: blue">=&quot;{</span><span style="color: #a31515">TemplateBinding </span><span style="color: red">ViewportWidth</span><span style="color: blue">}&quot; /&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">Grid</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">Border</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">ControlTemplate</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">Setter.Value</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">Setter</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">Style</span><span style="color: blue">&gt;      <br /></span></p>  <p>If you compare this with the default style for ScrollViewer, you’ll see it’s really just the original PLUS the two additional VisualStateGroups.</p>  <p>As a reminder, the <b>default style</b> for each control can be found within the System.Windows.xaml file in the following location on a 64-bit machine: C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Design\System.Windows.xaml </p>  <p>So the two additional VisualStateGroups are:</p>  <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">&lt;</span><span style="color: #a31515">VisualStateGroup </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;VerticalCompression&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;NoVerticalCompression&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionTop&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionBottom&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateGroup</span><span style="color: blue">&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualStateGroup </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;HorizontalCompression&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;NoHorizontalCompression&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionLeft&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">VisualState </span><span style="color: red">x</span><span style="color: blue">:</span><span style="color: red">Name</span><span style="color: blue">=&quot;CompressionRight&quot;/&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">VisualStateGroup</span><span style="color: blue">&gt;      <br /></span></p>  <p>The names are self explanatory; “CompressionLeft” means that the compression animation is happening on the ScrollViewer content towards the left side of the viewport.</p>  <p>There are eight combinations coming out of this: top, bottom, left, right, top-left (45 degree angle compression), top-right, bottom-left and bottom-right.</p>  <p>After overriding the default style, you can listen to the <a href="http://msdn.microsoft.com/en-us/library/system.windows.visualstategroup.currentstatechanging(v=VS.95).aspx"><b>CurrentStateChanging</b></a> event on the corresponding VisualStateGroup element.</p>  <p>To get to the ScrollViewer’s visual state group you need following (building on top of the standard WP7 project template):</p>  <p><span style="color: blue">private void </span>MainPage_Loaded(<span style="color: blue">object</span>sender, <span style="color: #2b91af">RoutedEventArgs </span>e)     <br />&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(!<span style="color: #2b91af">App</span>.ViewModel.IsDataLoaded)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">App</span>.ViewModel.LoadData();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(alreadyHookedScrollEvents)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return</span>;     <br />    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; alreadyHookedScrollEvents = <span style="color: blue">true</span>;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MainListBox.AddHandler(<span style="color: #2b91af">ListBox</span>.ManipulationCompletedEvent, (<span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">ManipulationCompletedEventArgs</span>&gt;)LB_ManipulationCompleted, <span style="color: blue">true</span>);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sb = (<span style="color: #2b91af">ScrollBar</span>)FindElementRecursive(MainListBox, <span style="color: blue">typeof</span>(<span style="color: #2b91af">ScrollBar</span>));     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sv = (<span style="color: #2b91af">ScrollViewer</span>)FindElementRecursive(MainListBox, <span style="color: blue">typeof</span>(<span style="color: #2b91af">ScrollViewer</span>));     <br />    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(sv != <span style="color: blue">null</span>)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: green">// Visual States are always on the first child of the control template      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #2b91af">FrameworkElement </span>element = <span style="color: #2b91af">VisualTreeHelper</span>.GetChild(sv, 0) <span style="color: blue">as</span><span style="color: #2b91af">FrameworkElement</span>;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(element != <span style="color: blue">null</span>)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">VisualStateGroup </span>group = FindVisualState(element, <span style="color: #a31515">&quot;ScrollStates&quot;</span>);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(group != <span style="color: blue">null</span>)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; group.CurrentStateChanging += <span style="color: blue">new</span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">VisualStateChangedEventArgs</span>&gt;(group_CurrentStateChanging);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">VisualStateGroup </span>vgroup = FindVisualState(element, <span style="color: #a31515">&quot;VerticalCompression&quot;</span>);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">VisualStateGroup </span>hgroup = FindVisualState(element, <span style="color: #a31515">&quot;HorizontalCompression&quot;</span>);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(vgroup != <span style="color: blue">null</span>)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; vgroup.CurrentStateChanging += <span style="color: blue">new</span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">VisualStateChangedEventArgs</span>&gt;(vgroup_CurrentStateChanging);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if</span>(hgroup != <span style="color: blue">null</span>)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; hgroup.CurrentStateChanging += <span style="color: blue">new</span><span style="color: #2b91af">EventHandler</span>&lt;<span style="color: #2b91af">VisualStateChangedEventArgs</span>&gt;(hgroup_CurrentStateChanging);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />    <br />&#160;&#160;&#160;&#160; } </p>  <p>&#160; <span style="color: blue">private </span><span style="color: #2b91af">UIElement </span>FindElementRecursive(<span style="color: #2b91af">FrameworkElement </span>parent, <span style="color: #2b91af">Type </span>targetType)     <br />&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">int </span>childCount = <span style="color: #2b91af">VisualTreeHelper</span>.GetChildrenCount(parent);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">UIElement </span>returnElement = <span style="color: blue">null</span>;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if </span>(childCount &gt; 0)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; childCount; i++)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">Object </span>element = <span style="color: #2b91af">VisualTreeHelper</span>.GetChild(parent, i);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if </span>(element.GetType() == targetType)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return </span>element <span style="color: blue">as </span><span style="color: #2b91af">UIElement</span>;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">else      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>{     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; returnElement = FindElementRecursive(<span style="color: #2b91af">VisualTreeHelper</span>.GetChild(parent, i) <span style="color: blue">as </span><span style="color: #2b91af">FrameworkElement</span>, targetType);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return </span>returnElement;     <br />&#160;&#160;&#160;&#160;&#160;&#160; }</p>  <p>   <br />&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">private </span><span style="color: #2b91af">VisualStateGroup </span>FindVisualState(<span style="color: #2b91af">FrameworkElement </span>element, <span style="color: blue">string </span>name)     <br />&#160;&#160;&#160;&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if </span>(element == <span style="color: blue">null</span>)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return null</span>;     <br />    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: #2b91af">IList </span>groups = <span style="color: #2b91af">VisualStateManager</span>.GetVisualStateGroups(element);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">foreach </span>(<span style="color: #2b91af">VisualStateGroup </span>group <span style="color: blue">in </span>groups)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">if </span>(group.Name == name)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return </span>group;     <br />    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return null</span>;     <br />&#160;&#160;&#160;&#160;&#160;&#160; } </p>  <p>This will be pretty easy to follow along with if you download and run the sample app. Let us know if this helps you complete your scrolling-related scenarios.    <br /></p>  <h4>Other important points</h4>  <ul>   <li>VerticalCompression and HorizontalCompression VisualStateGroups are available ONLY for 7.1 </li>    <li>Both are available ONLY for <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.manipulationmode(v=VS.96).aspx">ManipulationMode = System</a>,       <ul>       <li><a href="http://blogs.msdn.com/b/slmperf/archive/2011/06/02/listbox-scrollviewer-performance-improvement-for-mango-and-how-it-impacts-your-existing-application.aspx">What is ManipulationMode = System</a>? </li>     </ul>   </li>    <li>These groups are not part of the default style, but are available to use. </li>    <li>You can read about Control Syles and Templates in detail <a href="http://msdn.microsoft.com/en-us/library/cc278075(v=VS.95).aspx">here</a> </li> </ul>  <p>Thanks !</p>  <p>SLMPerf</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/18/21/76/ListBoxVisualStatesDemo.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-18-21-76/ListBoxVisualStatesDemo.zip">ListBoxVisualStatesDemo.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>WebClient change for Mango, how it impacts your application ?</title>
      <link>https://docs.microsoft.com/archive/blogs/slmperf/webclient-change-for-mango-how-it-impacts-your-application</link>
      <pubDate>Tue, 21 Jun 2011 18:20:00 GMT</pubDate>
      <dc:creator><![CDATA[SLMPerf]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/slmperf/2011/06/21/webclient-change-for-mango-how-it-impacts-your-application/</guid>
      <description><![CDATA[You, in this case is a developer who has published or will publish a Windows Phone 7.0/7.1 app.  In...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">You, in this case is a developer who has published or will publish a Windows Phone 7.0/7.1 app. </span></span></p> <p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">In WP7.0 we had recommended <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(VS.95).aspx">HttpWebRequest</a> over <a href="http://msdn.microsoft.com/en-us/library/system.net.webclient(v=VS.95).aspx">WebClient</a> in our <a href="http://blogs.msdn.com/b/slmperf/archive/2010/10/06/silverlight-for-windows-phone-7-listbox-scroll-performance.aspx">ListBox scrolling post for WP7</a>. Reason for recommending that was, in WP7.0, if the developer created a WebClient request from background thread (any thread actually), the response would always come back to the UIthread. This was causing unexpected heavy processing operations to happen on the UIthread, causing interactivity issues. So we recommended using HttpWebRequests. In HttpWebRequests, the response would come back on the thread where the request originated.</span></span></p> <p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">In Mango, 7.1 apps, we fixed the WebClient issue. So now, a WebClient request created from background thread will receive the response on the same thread. However, if the request is created on the UIthread, the response will come back on the UIthread, this is not recommended. Keeping the UIthread free from heavy processing should be the goal.</span></span></p> <h2><span style="font-size: medium" size="4"><span style="color: #4f81bd" color="#4f81bd"><span style="font-family: cambria" face="Cambria">How does this impact your application on upgrade from 7.0 to 7.1?</span></span></span></h2> <p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">If in 7.0 app, you have an application that created a WebClient request on background thread. Received the response on the UIThread (to update properties on the UI, example add item to your ObservableCollection, bound to ListBox or updated Text of a TextBlock), then on upgrade to 7.1 and running the application as is, will cause </span></span></p> <p><b><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">System.UnauthorizedAccessException: Invalid cross-thread access error</span></span></b></p> <p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">You developed your app with an assumption that the response will come back on the UIThread. However, with this change, the response will go back on the background thread causing the cross-thread access error.</span></span></p> <p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">Let us look at an example:</span></span></p> <p><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri"></span></span><br><span style="font-size: small" size="3"><span style="font-family: calibri" face="Calibri">Attached is a <b>7.0 app</b>, where we make a WebClient request on BackgroundWorker thread using Bing Image APIs and get a response back on the UIthread.</span></span></p> <div class="csharpcode"><pre class="code"><span style="color: blue">private void </span>backgroundWorker1_DoWork(<span style="color: blue">object </span>sender, <span style="color: #2b91af">DoWorkEventArgs </span>e)
       {
           <span style="color: green">//in a real world scenario this is something where heavy lifting happens on a </span></pre><pre class="code"><span style="color: green">background thread </span></pre><pre class="code"><span style="color: green"> </span><span style="color: #2b91af">WebClient </span>wc = <span style="color: blue">new </span><span style="color: #2b91af">WebClient</span>();
           wc.OpenReadCompleted += <span style="color: blue">new </span><span style="color: #2b91af">OpenReadCompletedEventHandler</span>(wc_OpenReadCompleted);
           <span style="color: #2b91af">UriBuilder </span>fullUri = <span style="color: blue">new </span><span style="color: #2b91af">UriBuilder</span>(<span style="color: #a31515">"http://api.bing.net/xml.aspx?"</span>);
           <span style="color: green">// Common request fields (required) </span>fullUri.Query = <span style="color: #a31515">"AppId=XXXXXX" </span>+ <span style="color: #a31515">"&amp;Query=" </span>+ _searchterm
           + <span style="color: #a31515">"&amp;Sources=Image"</span>;
           wc.OpenReadAsync(fullUri.Uri);
       }
</pre><pre>&nbsp;</pre></div>
<p>Then we update the UI after we received the response. <span style="background-color: #ffff00">Highlighted is the UIthread action</span>.</p>
<p>&nbsp;</p>
<div class="csharpcode"><pre class="code"><span style="color: blue">void </span>wc_OpenReadCompleted(<span style="color: blue">object </span>sender, <span style="color: #2b91af">OpenReadCompletedEventArgs </span>e)
       {
           <span style="color: #2b91af">Stream </span>streamResult = e.Result;
           <span style="color: #2b91af">XElement </span>xmlBingImages = <span style="color: #2b91af">XElement</span>.Load(streamResult);
           <span style="color: blue">string </span>mms = <span style="color: #a31515">"http://schemas.microsoft.com/LiveSearch/2008/04/XML/multimedia"</span>;
           <span style="color: blue">var </span>TEMP = xmlBingImages.DescendantNodes();           
           <span style="color: blue">int </span>totalResults = <span style="color: #2b91af">Convert</span>.ToInt32(xmlBingImages.Descendants(<span style="color: #a31515">"{" </span>+ mms + <span style="color: #a31515">"}Total"</span>).First().Value);
           </pre><span style="background-color: #ffff00">WebClientSampleText.Text = <span style="color: #a31515">"Total# of Bing image results: "</span>+totalResults.ToString();</span> <pre class="code">            
       }
</pre><pre></pre></div>
<p>As an exercise, right click on the project from VS2010, upgrade to 7.1</p>
<p>Debug the application. You will see the following exception</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/metablogapi/0841.image_3D3A7715.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80-metablogapi/0841.image_5F00_3D3A7715.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/metablogapi/2072.image_thumb_6ABB96D8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80-metablogapi/2072.image_5F00_thumb_5F00_6ABB96D8.png" width="534" height="347"></a></p>
<p>&nbsp;</p>
<p>And this is how we work around it</p>
<div class="csharpcode"><pre class="code"><span style="color: #2b91af">Deployment</span>.Current.Dispatcher.BeginInvoke(() =&gt;
            {
                WebClientSampleText.Text = <span style="color: #a31515">"Total# of Bing image results: " </span>+ totalResults.ToString();
            });
</pre><pre></pre></div>
<p>Goal of this post is to inform the developers(upgrading from 7.0 to 7.1) about this possible change, they will have to make, if they run into the cross-thread access error.</p>
<p>Thanks</p>
<p>[PS: This was published initially with some glaring grammar mistakes, sorry about that. Was published in a hurry. Got the feedback. It wont be 100% perfect grammatically, but I will try better next time.&nbsp; Constructive criticism is appreciated.]</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/17/76/44/WebClient70Sample.zip" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-17-76-44/WebClient70Sample.zip">WebClient70Sample.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Off-thread decoding of images on Mango, how it impacts your application ?</title>
      <link>https://docs.microsoft.com/archive/blogs/slmperf/off-thread-decoding-of-images-on-mango-how-it-impacts-your-application</link>
      <pubDate>Mon, 13 Jun 2011 16:44:00 GMT</pubDate>
      <dc:creator><![CDATA[SLMPerf]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/slmperf/2011/06/13/off-thread-decoding-of-images-on-mango-how-it-impacts-your-application/</guid>
      <description><![CDATA[The part 1 of the SLMPerf Mango blog post series was posted here, where we spoke about ListBox in...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: calibri; font-size: small">The part 1 of the SLMPerf Mango blog post series was posted </span><a href="http://blogs.msdn.com/b/slmperf/archive/2011/06/02/listbox-scrollviewer-performance-improvement-for-mango-and-how-it-impacts-your-existing-application.aspx"><span style="font-family: calibri; color: #0000ff; font-size: small">here</span></a><span style="font-size: small"><span style="font-family: calibri">, where we spoke about ListBox in general. We will take it up one step further and reach out for a deeper (and common) scenario related to ListBox. </span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">We see the following template very often for WP7 apps.</span></span><span style="font-family: consolas; color: #0000ff; font-size: x-small"><span style="font-family: consolas; color: #0000ff; font-size: x-small"><span style="font-family: consolas; color: #0000ff; font-size: x-small"><span style="font-family: consolas; color: #0000ff; font-size: x-small">&#160;</span></span></span></span></p>  <p class="MsoNormal"></p>  <p><span style="font-family: consolas; color: #0000ff; font-size: x-small"><span style="font-family: consolas; color: blue; font-size: 9.5pt"></span>      <p class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> ItemsSource</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Items</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Height</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;652&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Canvas.Top</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;80&quot;&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox.ItemTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">DataTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Orientation</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;Horizontal&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Margin</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;0,0,0,17&quot;&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Image</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Height</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;100&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Width</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;100&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Margin</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;12,0,9,0&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Source</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> ImgURL</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;/&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Width</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;311&quot;&gt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">TextBlock</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Text</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> LineOne</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> TextWrapping</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;Wrap&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Style</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StaticResource</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> PhoneTextExtraLargeStyle</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;/&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">TextBlock</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Text</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> LineTwo</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> TextWrapping</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;Wrap&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Margin</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;12,-6,12,0&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Style</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StaticResource</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> PhoneTextSubtleStyle</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;/&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">DataTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox.ItemTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>      <p class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;<span style="mso-tab-count: 1">&#160;&#160;&#160;&#160; </span><o:p></o:p></span></p>      <p class="MsoNormal">&#160;</p>   </span></p>&#160; <span style="font-family: calibri; font-size: small">There was one room for improvement on the platform side that we had identified. For this above scenario running on WP7, the decoding of the image happened on the UI thread. The decoding process time was proportional to the size of the image. More time UI thread spent on such processing, less time it had for interactivity.</span>      <p>&#160;</p>  <p><span style="font-family: calibri; font-size: small">So we decided to move the decoding off to a separate background thread.&#160; The goodness of this change can be seen using the </span><a href="http://cid-3556d9296e17cf90.skydrive.live.com/redir.aspx?resid=3556D9296E17CF90!122"><span style="font-family: calibri; color: #0000ff; font-size: small">attached sample</span></a>, LargeListBoxImageDecoding<span style="font-size: small"><span style="font-family: calibri"> (it’s a huge sample as the images are local in the project).</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Here are the pretty diagrams demonstrating the change.</span></span><span style="font-family: calibri; font-size: small">&#160;</span></p>  <p><span style="font-family: calibri; font-size: small">&#160; This is how it will be for WP7/Mango default:</span></p>  <p><span style="font-family: calibri; font-size: small">&#160;</span>&#160;<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/5415.WP7Decoding.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80/5415.WP7Decoding.jpg"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/5415.WP7Decoding.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80/5415.WP7Decoding.jpg" /></a></p>  <p>Here is how it will be with BackgroundCreation</p>  <p><span style="font-family: calibri; font-size: small">&#160;</span></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/4336.MangoDecoding.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80/4336.MangoDecoding.jpg"><img border="0" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/40/80/4336.MangoDecoding.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-40-80/4336.MangoDecoding.jpg" /></a></p>  <p><span style="font-family: calibri; font-size: small">     <br /></span></p>  <h1><span style="color: #365f91"><span style="font-family: cambria">Opt-In property</span></span></h1>  <p><span style="font-family: calibri; font-size: small">&#160;</span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Moving the image decoding to a background thread resulted in behavioral change for some existing app, so we had to introduce a new property for developers to opt into this goodness for 7.1</span></span></p>  <p><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapcreateoptions(v=VS.95).aspx"><span style="font-family: calibri; color: #0000ff; font-size: small">http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapcreateoptions(v=VS.95).aspx</span></a><span style="font-size: small"><span style="font-family: calibri"> </span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">If you see “Do Not use” at the above link, it will be updated soon.</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">This is a flagwise enum, here is how the combinations should work</span></span></p>  <p><span style="font-family: calibri; font-size: small">&#160;</span></p>  <table border="1" cellspacing="0" cellpadding="0"><tbody>     <tr>       <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">CreateOptions</span></span></p>       </td>        <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">Functional Behavior</span></span></p>       </td>     </tr>      <tr>       <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">None</span></span></p>       </td>        <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">Same has before, None&#160; </span></span></p>       </td>     </tr>      <tr>       <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">DelayCreation </span></span></p>       </td>        <td valign="top" width="348">         <p><span style="font-family: calibri; font-size: small">Causes a </span><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapsource(v=VS.95).aspx"><span style="font-family: calibri; color: #0000ff; font-size: small">BitmapSource</span></a><span style="font-family: calibri; font-size: small"> object to delay initialization until it is necessary. This is useful when dealing with collections of images. <span style="background-color: #ffff00"><b>This is the default value in WP7(and Mango) of the</b> </span></span><a href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage.createoptions(v=VS.95).aspx"><span style="font-family: calibri; color: #0000ff; font-size: small">BitmapImage.CreateOptions</span></a><span style="font-size: small"><span style="font-family: calibri"> property in Silverlight.</span></span></p>       </td>     </tr>      <tr>       <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">IgnoreImageCache</span></span></p>       </td>        <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">Loads images without using an existing image cache. This option should only be selected when images in a cache need to be refreshed.</span></span></p>       </td>     </tr>      <tr>       <td valign="top" width="348">         <p><b><span style="font-size: small"><span style="font-family: calibri">BackgroundCreation</span></span></b></p>       </td>        <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">Causes object to initialize as soon as declared, uses image cache for same URIs, downloads images in background and decodes them in background.</span></span></p>       </td>     </tr>      <tr>       <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri"><b>BackgroundCreation</b>,DelayCreation</span></span></p>       </td>        <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">Causes object to delay initialization until it is necessary, uses image cache for same URIs, downloads images in background and decodes them in background.</span></span></p>          <p><span style="background-color: #ffff00"><b><span style="font-size: small"><span style="font-family: calibri">This is default in Beta but we reverted the change, as it caused a lot of developer pain on upgrade to 7.1, we will talk about it below.</span></span></b></span></p>       </td>     </tr>      <tr>       <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri"><b>BackgroundCreation</b>,DelayCreation,IgnoreImageCache</span></span></p>       </td>        <td valign="top" width="348">         <p><span style="font-size: small"><span style="font-family: calibri">Causes object to delay initialization until it is necessary., ignores image cache for same URIs, downloads images in background and decodes them in background.</span></span></p>       </td>     </tr>   </tbody></table>  <p><span style="font-family: calibri; font-size: small">&#160;</span></p>  <p><span style="font-size: small"><span style="font-family: calibri">The usage of the property for our scenario will be&#160; as highlighted below</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">&#160;</span></span>&#160;</p>  <p class="MsoNormal"></p>  <p><span style="font-size: small"><span style="font-family: calibri"><span style="font-family: consolas; color: blue; font-size: 9.5pt"></span>        <p class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> ItemsSource</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Items</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Height</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;652&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Canvas.Top</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;80&quot;&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox.ItemTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">DataTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Orientation</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;Horizontal&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Margin</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;0,0,0,17&quot;&gt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Image</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Height</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;100&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Width</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;100&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Margin</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;12,0,9,0&quot; &gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Image.Source</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow">&lt;</span><span style="font-family: consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow">BitmapImage</span><span style="font-family: consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow"> UriSource</span><span style="font-family: consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow">=&quot;{</span><span style="font-family: consolas; background: yellow; color: #a31515; font-size: 9.5pt; mso-highlight: yellow">Binding</span><span style="font-family: consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow"> ImgURL</span><span style="font-family: consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow">}&quot;</span><span style="font-family: consolas; background: yellow; color: red; font-size: 9.5pt; mso-highlight: yellow"> CreateOptions</span><span style="font-family: consolas; background: yellow; color: blue; font-size: 9.5pt; mso-highlight: yellow">=&quot;BackgroundCreation&quot;/&gt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160; </span></span><span style="font-family: consolas; color: green; font-size: 9.5pt">&lt;!-- flip this to none or delay creation to see the impact on the app--&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Image.Source</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Image</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Width</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;311&quot;&gt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">TextBlock</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Text</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> LineOne</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> TextWrapping</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;Wrap&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Style</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StaticResource</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> PhoneTextExtraLargeStyle</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;/&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">TextBlock</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Text</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Binding</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> LineTwo</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> TextWrapping</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;Wrap&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Margin</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;12,-6,12,0&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> Style</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;{</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StaticResource</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> PhoneTextSubtleStyle</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">}&quot;/&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">StackPanel</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">DataTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox.ItemTemplate</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>        <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ListBox</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;<o:p></o:p></span></p>        <p class="MsoNormal">&#160;</p>     </span></span></p>&#160;&#160;     <p><span style="font-size: large"><strong><span style="color: #4f81bd"><span style="font-family: cambria">Impact of BackgroundCreation</span></span></strong></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Defaults: We recognized offthread-decoding or asynchronous decoding as a good pattern that the developers should follow and <i>wanted to make it a default</i> for the new 7.1 application. Existing 7.0 applications will not be impacted by this change.</span></span></p>  <p><span style="font-family: calibri; font-size: small">So in </span><a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=77586864-ab15-40e1-bc38-713a95a56a05&amp;displaylang=en"><span style="font-family: calibri; color: #0000ff; font-size: small">the mango tools</span></a><span style="font-size: small"><span style="font-family: calibri"> we experimented and kept offthread decoding (BackgroundCreation) as a default. However, we saw several beta developers feel some pain when they upgraded their app from 7.0 to 7.1</span></span></p>  <p><b><span style="font-size: small"><span style="font-family: calibri">Change#1</span></span></b></p>  <p class="MsoNormal"></p>  <div class="MsoNormal"><span style="font-family: consolas; color: #2b91af; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160; </span></span></div>    <p><span style="font-family: consolas; color: #2b91af; font-size: 9.5pt"><span style="mso-spacerun: yes"></span>      <p class="MsoNormal"><span style="font-family: consolas; color: #2b91af; font-size: 9.5pt">&#160;&#160;&#160;&#160; BitmapImage</span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"> b = </span><span style="color: blue">new</span><span style="color: #000000"> </span><span style="color: #2b91af">BitmapImage</span><span style="color: #000000">();<o:p></o:p></span></span></p>      <p class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>b.CreateOptions = </span><span style="color: #2b91af">BitmapCreateOptions</span><span style="color: #000000">.BackgroundCreation;<o:p></o:p></span></span></p>      <p class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>b.SetSource(stream);<o:p></o:p></span></span></p>      <p class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>b.PixelHeight, b.PixelWidth<o:p></o:p></span></span></p>      <p class="MsoNormal">&#160;</p>   </span></p>    <p><span style="font-size: small"><span style="font-family: calibri">// now do something with b.PixelWidth/PixelHeight, these values are 0 till the decoding is completed. Use mitigation.</span></span></p>  <p><b><span style="font-size: small"><span style="font-family: calibri">Change#2          <br /></span></span></b></p>    <p><span style="font-size: small"><span style="font-family: calibri"></span>      <p class="MsoNormal"></p>      <div class="MsoNormal"><span style="font-family: consolas; color: #2b91af; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></div>           <span style="font-family: consolas; color: #2b91af; font-size: 9.5pt"><span style="mso-spacerun: yes">         <p class="MsoNormal"><span style="font-family: consolas; color: #2b91af; font-size: 9.5pt">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BitmapImage</span><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"> b = </span><span style="color: blue">new</span><span style="color: #000000"> </span><span style="color: #2b91af">BitmapImage</span><span style="color: #000000">();<o:p></o:p></span></span></p>          <p class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>b.CreateOptions = </span><span style="color: #2b91af">BitmapCreateOptions</span><span style="color: #000000">.BackgroundCreation;<o:p></o:p></span></span></p>          <p class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="color: #000000"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>b.SetSource(stream);<o:p></o:p></span></span></p>          <p class="MsoNormal"><span style="font-family: consolas; font-size: 9.5pt"><span style="mso-spacerun: yes"><span style="color: #000000">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="color: #2b91af">WriteableBitmap</span><span style="color: #000000"> wbp = </span><span style="color: blue">new</span><span style="color: #000000"> </span><span style="color: #2b91af">WriteableBitmap</span><span style="color: #000000">(b);<o:p></o:p></span></span></p>          <p class="MsoNormal">&#160;</p>       </span></span>      <p>&#160;</p>   </span></p> <span style="font-size: small"><span style="font-family: calibri">//this will throw a null ref exception as you cannot create a wbp for the bits that aren’t yet decoded. Use mitigation.</span></span>      <p><b><span style="font-size: small"><span style="font-family: calibri">Mitigations:</span></span></b></p>  <p><span style="font-family: calibri; font-size: small">For both the cases above, you can resolve by waiting for </span><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imageopened(v=vs.95).aspx"><span style="font-family: calibri; color: #0000ff; font-size: small">ImageOpened</span></a><span style="font-family: calibri; font-size: small"> event, and checking if </span><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imagefailed(v=vs.95).aspx"><span style="font-family: calibri; color: #0000ff; font-size: small">ImageFailed</span></a><span style="font-size: small"><span style="font-family: calibri"> isn’t fired.</span></span></p>  <p><b><span style="font-size: small"><span style="font-family: calibri">Change#3</span></span></b></p>  <p><span style="font-size: small"><span style="font-family: calibri">This will be a little difficult to imagine. It’s a subtle behavior change that you might notice in your app. </span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Scenario here is, you update the URL of the image (could be part of listbox item), from URL1 to URL2.</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">With DelayCreation, since the decoding is happening on the UI thread, the image for URL2 won’t show up till the decoding is completed. As soon as the decoding is completed, URL1 image is replaced by ULR2 image. UI thread is bogged down, so less interactivity.</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">With BackgroundCreation, however, the decoding will happen on a background thread. Which means the UI thread is free to update the UI; while URL2 image is being decoded in the background, URL1 image is replaced by a momentary “blank” and as soon as the URL2 image is decoded, it appears in place of the blank. Resulting in what might looks like a momentary flicker or change in behavior. <b><i>Depending on your app, this might be desirable or not.</i></b></span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">You will notice this in the sample when you change the URL. Play with the property to see the impact yourself. </span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">As another example, you can experiment with the panorama, create a basic panorama application using the pano template. Add the following code to it</span></span><span style="font-family: calibri; font-size: small">&#160;</span><span style="font-size: small"><span style="font-family: calibri"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160; </span></span></span></span></p>          <p><span style="font-family: consolas; color: blue; font-size: 9.5pt"></span>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">controls</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">:</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Panorama.Background</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ImageBrush</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ImageBrush.ImageSource</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">BitmapImage</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> CreateOptions</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot; BackgroundCreation<o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: blue; font-size: 9.5pt">&quot;</span><span style="font-family: consolas; color: red; font-size: 9.5pt"> UriSource</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">=&quot;PanoramaBackground.jpg&quot;&gt;&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">BitmapImage</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt; &lt;!--or png--&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ImageBrush.ImageSource</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">ImageBrush</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;</span><span style="font-family: consolas; font-size: 9.5pt"><o:p></o:p></span></p>    <p class="MsoNormal"><span style="font-family: consolas; color: #a31515; font-size: 9.5pt"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&lt;/</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">controls</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">:</span><span style="font-family: consolas; color: #a31515; font-size: 9.5pt">Panorama.Background</span><span style="font-family: consolas; color: blue; font-size: 9.5pt">&gt;<o:p></o:p></span></p>    <p class="MsoNormal">&#160;</p> </p>      &#160;&#160;     <p><span style="font-size: small"><span style="font-family: calibri">Launch the app on device and see the change</span></span></p>  <ol>   <li>&#160;<span style="font-size: small"><span style="font-family: calibri">With BackgroundCreation: the app launches and the panorama background animates in, what appears like a flicker. Or a delayed appearance of the background. This is because the image is still being downloaded in the background while everything else has started to appear.</span></span> </li>    <li>&#160;<span style="font-size: small"><span style="font-family: calibri">With DelayCreation: the app launches and the panorama background animates in as expected, smoothly without any flicker. This is because, we don’t proceed until the background image decoding is completed. </span></span></li> </ol>  <p><span style="font-family: calibri; font-size: small">&#160;</span></p>  <h2><span style="font-size: medium"><span style="color: #4f81bd"><span style="font-family: cambria">When do you use BackgroundCreation ?</span></span></span></h2>  <p><span style="font-size: small"><span style="font-family: calibri">The question should be other way actually, when to NOT use BackgroundCreation ? If your application is impacted by BackgroundCreation, as described in the previous section, then you shouldn’t use it. Otherwise, in all other scenarios, having BackgoundCreation for images is nothing but goodness for your application’s UIThread.</span></span></p>  <p><span style="font-size: small"><span style="font-family: calibri">Use background creation wherever possible as it, in a very subtle way, improves the interactivity of the application. </span></span></p>  <p><span style="font-family: calibri"><b>The goodness of this change is linearly proportional to the size of the images. </b></span></p>  <p><span style="font-family: calibri; font-size: small">[Edit update – 8/1/2011]&#160; - removed the ‘More optimizations’ section as it is no longer relevant for Mango.</span></p>  <div style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px" id="_mcePaste" class="mcePaste">﻿</div>]]></content:encoded>
    </item>
    <item>
      <title>Listbox – ScrollViewer performance improvement for Mango and how it impacts your existing application?</title>
      <link>https://docs.microsoft.com/archive/blogs/slmperf/listbox-scrollviewer-performance-improvement-for-mango-and-how-it-impacts-your-existing-application</link>
      <pubDate>Thu, 02 Jun 2011 17:13:00 GMT</pubDate>
      <dc:creator><![CDATA[SLMPerf]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/slmperf/2011/06/02/listbox-scrollviewer-performance-improvement-for-mango-and-how-it-impacts-your-existing-application/</guid>
      <description><![CDATA[﻿
&nbsp;We have heard this over and over, having a smooth scrolling ListBox on Windows Phone is a...]]></description>
      <content:encoded><![CDATA[<div class="mcePaste" id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;">﻿</div>
<p>&nbsp;We have heard this over and over, having a smooth scrolling ListBox on Windows Phone is a core scenario. We received feedback on WP7 that the listbox scrolling experience for applications is not at par with the native applications on the phone, like Outlook. We absorbed all the feedback and optimized this experience as can be seen in <a href="https://channel9.msdn.com/Events/MIX/MIX11/KEY02"><span style="color: #0000ff;">Scott&rsquo;s key note</span></a> demo at MIX11 @ 01:02:25.&nbsp;</p>
<p><b><i>Interactivity</i></b> -&nbsp; response to touch, the sense of the ListBox(<i>ScrollViewer</i>) responding to your touch almost instantaneously keeps your apps&rsquo; end user gripped to the application and was among the first things we wanted to improve. To do this we had to move the listening of the touch gestures to a separate thread. This meant an architecture level change for how we listened to the gestures and the response to these gestures for scrolling animations. We deftly handled various threads, one each for input (Input thread), animations (Compositor thread), and creating new items (UI thread).&nbsp;</p>
<p>We made this sweetness available for all the applications, irrespective of the version of your app. As soon as the end user upgrades the phone to <i>Mango</i> update all the existing applications on their phone will get this new improved smooth scrolling experience.&nbsp;</p>
<p>What does this mean for application authors?? <b><i>Developers have to do NOTHING to get these improvements.</i></b>&nbsp;</p>
<p><strong>Unless</strong>&hellip; performance improvements don&rsquo;t just come without removing some extra work that was happening. We had to make changes to reduce the load on the UI thread by reducing the update frequency of a few lower priority events and properties.&nbsp;</p>
<p>So we have the following low impact minor changes:&nbsp;</p>
<table cellpadding="0" cellspacing="0" border="0" class="MsoNormalTable" style="margin: auto auto auto 0.5in; border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 0in 0in 0in;">
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;">
<td width="167" valign="top" style="padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 125.6pt; padding-right: 5.4pt; padding-top: 0in; border: windowtext 1pt solid;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Scenario<o:p></o:p></span></p>
</td>
<td width="198" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 148.5pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">7.0 App on <b style="mso-bidi-font-weight: normal;">WP7</b><o:p></o:p></span></p>
</td>
<td width="318" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 238.5pt; padding-right: 5.4pt; border-top: windowtext 1pt solid; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><b style="mso-bidi-font-weight: normal;"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">7.0 and 7.1</span></b><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;"> App on <b style="mso-bidi-font-weight: normal;">Mango</b><o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 1;">
<td width="167" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 125.6pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Updating all ScrollViewer properties on the UI thread when scrolling.<o:p></o:p></span></p>
</td>
<td width="198" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 148.5pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Happens as soon as the properties change<o:p></o:p></span></p>
</td>
<td width="318" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 238.5pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Happens only when<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">a. Finger is lifted or<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">b. Drags/pans/flicks move more than 1/4th of the screen in any direction<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">If this impacts your app, follow the <b style="mso-bidi-font-weight: normal;">mitigation</b>*<o:p></o:p></span></p>
</td>
</tr>
<tr style="mso-yfti-irow: 2; mso-yfti-lastrow: yes;">
<td width="167" valign="top" style="border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 125.6pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Raising Manipulation Delta events on UI thread when dragging inside ScrollViewer<o:p></o:p></span></p>
</td>
<td width="198" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 148.5pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Will be available to be handled by the elements in the ScrollViewer<o:p></o:p></span></p>
</td>
<td width="318" valign="top" style="border-bottom: windowtext 1pt solid; border-left: #f0f0f0; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 238.5pt; padding-right: 5.4pt; border-top: #f0f0f0; border-right: windowtext 1pt solid; padding-top: 0in;">
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">Will be swallowed by the ScrollViewer, as they are on the input thread, This is part of the performance improvement where we don&rsquo;t raise unnecessary series of events to optimize the core scrolling experience<o:p></o:p></span></p>
<p class="MsoListParagraph"><span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-font-family: 'Times New Roman'; mso-bidi-theme-font: minor-bidi;">If this impacts your app, follow the <b style="mso-bidi-font-weight: normal;">mitigation</b>*<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h2><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">What is your responsibility as App Developer?</span></span></span></h2>
<p>&nbsp;Test your app on the latest Mango tools as soon as possible. Look for subtle impact of this change on your application.&nbsp;</p>
<p><b>There is an extremely low probability that your application is *negatively* impacted by this change.&nbsp;</b>&nbsp;</p>
<h2><span style="font-size: medium;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Mitigations*</span></span></span></h2>
<p>&nbsp;If you find yourself in a position where your app is doing something we did not anticipate or is being impacted by a scenario where we picked performance over functionality, then the following the mitigation routes are available.</p>
<h3><span style="font-size: small;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Option #1: Opt-out of this improvement.</span></span></span></h3>
<p>Not recommended, and not preferred option, available only for special apps that cannot work without the events/properties being updated like the WP7 version.&nbsp;&nbsp;</p>
<p>In that case:</p>
<ol>
<li>Upgrade your application to 7.1</li>
<li>Opt out of this improvement by using the following property on ScrollViewer:</li>
</ol>
<p>&nbsp;</p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">ListBox</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> ItemsSource</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">="{</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">Binding</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> Items</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">}"</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> ScrollViewer.<span style="background: yellow;">ManipulationMode</span></span><span style="font-family: Consolas; background: yellow; color: blue; font-size: 9.5pt;"> ="Control"</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> Height</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">="652"</span><span style="font-family: Consolas; color: red; font-size: 9.5pt;"> Canvas.Top</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">="80"&gt;</span><span style="font-family: 'Calibri','sans-serif'; font-size: 11pt;"><o:p></o:p></span></p>
<p>&nbsp;</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.manipulationmode(VS.95).aspx"><span style="color: #0000ff;">http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.manipulationmode(VS.95).aspx</span></a> </p>
<p>If it says &ldquo;Do Not Use&rdquo; then above link is not updated yet. </p>
<p>&nbsp;</p>
<p>Following will be edited and published at the above link:</p>
<p>&nbsp;</p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">enum</span> <span style="color: #2b91af;">ManipulationMode</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Controls can handle their own interactivity and all listbox properties/events/methods available</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Control,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// Default, System takes over optimizing the interactivity experience, limiting the frequency and availability of properties/events/methods</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>System<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//Lets you select the Gesture interactivity for the scrollviewer/listbox and should be set once</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: #2b91af;">ManipulationMode</span> ManipulationMode { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<table width="609" cellpadding="0" cellspacing="0" border="1">
<tbody>
<tr>
<td width="16" valign="top">
<p>Exception</p>
</td>
<td width="593" valign="top">
<p>Condition</p>
</td>
</tr>
<tr>
<td width="16" valign="top">
<p><a href="http://msdn.microsoft.com/en-us/library/system.invalidoperationexception(v=VS.95).aspx">InvalidOperationException</a></p>
</td>
<td width="593" valign="top">
<p>The&nbsp;ManipulationMode has already been set and cannot be changed after<span style="font-family: Times New Roman; font-size: small;"> </span><a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.listbox.onapplytemplate(v=VS.95).aspx">OnApplyTemplate</a><span style="font-family: Times New Roman; font-size: small;"> ()</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<h3><span style="font-size: small;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Option #2: Modify the application code to work around the changed behavior</span></span></span></h3>
<p>&nbsp;If your app is doing something that&nbsp;is taking a dependency for the properties/events to be updated as soon as they happen then we would strongly recommend to remove those dependencies.&nbsp;</p>
<p>Top example that falls in this bucket is if you have a TextBlock within a ScrollViewer with HorizontalScrolling Enabled and this TextBlock is part of a Panorama Item. You will see a slight delay in pano item swap when you do a slow horizontal drag within the TextBlock.</p>
<p>&nbsp;This is due to Panorama wanting to listen the gestures of all its child controls, but in this case the child control&rsquo;s gesture is on a separate thread that doesn&rsquo;t bubble up the manipulation deltas. For this particular case, just turn off the horizontal scrolling for the TextBlock&rsquo;s ScrollViewer. It is against the <a href="http://download.microsoft.com/download/D/8/6/D869941E-455D-4882-A6B8-0DBCAA6AF2D4/UI%20Design%20and%20Interaction%20Guide%20for%20Windows%20Phone%207%20Series.pdf"><span style="color: #0000ff;">Metro UI guidelines</span></a> anyway.&nbsp;</p>
<p>Build a community for changes like these, blog about the corner cases you run into, platform will do the same.</p>
<p>&nbsp;</p>
<h3><span style="font-size: small;"><span style="color: #4f81bd;"><span style="font-family: Cambria;">Where this change doesn&rsquo;t apply ?</span></span></span></h3>
<p>&nbsp;</p>
<p>If your application is not using the Silverlight ListBox and/or ScrollViewer, you will not get the benefits of this change directly.&nbsp;&nbsp;</p>
<p>Example, if you are using the existing version of the Silverlight Toolkit <b>LongListSelector </b>you will not see this improvement after the Mango update directly. In that case, you will need to get a newer version of the controls that have been re-written to take advantage of the improvements. Update you application to use the newer controls and then you will see the improvements.</p>
<p>&nbsp;</p>
<p>Looking forward to feedback and comments.</p>
<p>&nbsp;</p>
<p>Thanks and let the &ldquo;buttery&rdquo; smooth scrolling make your end user slip into paying you more for your app !</p>
<p>&nbsp;</p>
<p><b>Silverlight Mobile Performance Team.</b></p>]]></content:encoded>
    </item>
    <item>
      <title>Silverlight for Windows Phone 7 Performance Session at PDC!</title>
      <link>https://docs.microsoft.com/archive/blogs/slmperf/silverlight-for-windows-phone-7-performance-session-at-pdc</link>
      <pubDate>Thu, 28 Oct 2010 00:13:00 GMT</pubDate>
      <dc:creator><![CDATA[Oren Nachman]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/slmperf/2010/10/28/silverlight-for-windows-phone-7-performance-session-at-pdc/</guid>
      <description><![CDATA[&nbsp;
It's that time of year again - PDC 2010 kicks of tomorrow! Join the Silverlight Performance...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p>
<p>It's that time of year again - PDC 2010 kicks of tomorrow! Join the Silverlight Performance Team as we take you through the high level analysis of common performance issues that apps commonly run into. I'll be giving a live session titled "Optimizing Performance for Silverlight WP7 Apps" at 3:15pm (PDT)&nbsp;&nbsp;on day 1 (28 October 2010).</p>
<p>Even if you couldn't make it here to heckle me in person, the rest of the team will be online and answering your questions (or heckling on your behalf) as you watch the live stream via the online player, which you'll be able to find at <a href="http://player.microsoftpdc.com">http://player.microsoftpdc.com</a>&nbsp;</p>
<p>Make sure to check out the session before mine ("Things I Wish I Knew about Building WP7 Apps" by&nbsp;<a href="http://blogs.msdn.com/b/jaimer/">Jaime&nbsp;Rodriguez</a>) and all of the rest of the&nbsp;<a href="http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/10/26/make-sure-you-don-t-miss-windows-phone-sessions-during-pdc10.aspx">Windows Phone 7</a>track. There's other great content at PDC that's worth checking out, but we all know that that's secondary!</p>
<p>See you there!</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Silverlight for Windows Phone 7: ListBox Scroll Performance</title>
      <link>https://docs.microsoft.com/archive/blogs/slmperf/silverlight-for-windows-phone-7-listbox-scroll-performance</link>
      <pubDate>Wed, 06 Oct 2010 17:40:00 GMT</pubDate>
      <dc:creator><![CDATA[SLMPerf]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/slmperf/2010/10/06/silverlight-for-windows-phone-7-listbox-scroll-performance/</guid>
      <description><![CDATA[Having a basic list scoll is a key scenario for many applications. The Silverlight Windows Phone 7...]]></description>
      <content:encoded><![CDATA[<p>Having a basic list scoll is a key scenario for many applications. The Silverlight Windows Phone 7 list box control makes it easy to bind data and get the performance benefits of UI container virtualization. However, in order to get these free performance benefits you need to be careful about how you use it. </p>  <p>Here are some tips on how to tweek your list box scroll performance.</p>  <h3>Simplify ListBox Item</h3>  <p>Listbox's VirtualizingStackPanel (VSP), calculates the height of items currently in the view and buffers the UI containers for a screens worth of items above and below what is currently in the view. This works great if the items are of fixed size. If you change the size of the items, the UI virtualization breaks and you don't get any performance benefits. </p>  <ul>   <li>Ensure you have the item data template in a fixed sized container (grid). </li>    <li>Avoid/remove using complex converters, when the same information can be easily provided by the data object. </li>    <li>Avoid/remove nested structures, example listbox in a listbox item. </li>    <li>Strongly recommended to not use user control inside the data template. </li>    <li>Avoid/remove custom controls from the data template </li> </ul>  <h3>Load the images in background </h3>  <p>If you have refered to the <a href="http://blogs.msdn.com/b/rohantha/archive/2010/09/09/optimizing-silverlight-applications-for-windows-phone-7.aspx">performance document</a>, you will know the importance of keeping the UI thread free for better responsiveness to handle input. This means that if you load the images on the UI thread, an input like flick might be lost. David talks about how to move the image loading to a single background thread in his blog <a href="http://blogs.msdn.com/b/delay/archive/2010/09/02/keep-a-low-profile-lowprofileimageloader-helps-the-windows-phone-7-ui-thread-stay-responsive-by-loading-images-in-the-background.aspx">LowProfileImageLoader</a>. </p>  <h3>Use Data Virtualization</h3>  <p>When using ListBox, UI is virtualized, the data is not -- so although a 1,000 item list only has a fraction of the UI elements created, it needs all 1,000 of the data objects created and loaded, which can be a resource issue (long load times / high memory usage). This is because in desktop Silverlight the <strong>ListBox </strong>and other controls databind to <strong>IEnumerables</strong>, where the only option the control has is to enumerate the entire list to find out how large it is. Peter has a solution to this in his post on <a href="http://blogs.msdn.com/b/ptorr/archive/2010/08/16/virtualizing-data-in-windows-phone-7-silverlight-applications.aspx">Data Virtualization</a>.</p>  <h3>Do not use ListBox**</h3>  <p>If your application demands variable height items, but the number of items is managable enough to keep in memory. You should consider a solution without list box, example: David Anson talks about how to use StackPanel instead of a ListBox in his post on <a href="http://blogs.msdn.com/b/delay/archive/2010/09/08/never-do-today-what-you-can-put-off-till-tomorrow-deferredloadlistbox-and-stackpanel-help-windows-phone-7-lists-scroll-smoothly-and-consistently.aspx">DefferedLoadListBox from Delay</a> in order to get good performance from a scenario that's pretty common for social media applications: a scrolling list of entries with a picture and a brief bit of text. Its easy to try it out for your application.</p>  <h3>Do not use Nested ListBox</h3>  <p>If you have a need for nested list boxes, you should consider a solution similar to <a href="http://blogs.msdn.com/b/delay/archive/2010/03/17/confessions-of-a-listbox-groupie-using-ivalueconverter-to-create-a-grouped-list-of-items-simply-and-flexibly.aspx">ListBoxGroupie</a></p>  <h3>Other tips/approaches</h3>  <ul>   <li>HttpWebRequest must be used instead of WebClient. The reason for this is, there is a current platform issue where a request created via WebClient always returns on the UI thread, and again, we know that keeping the UI thread free is important.&#160; Note: this is fixed in Mango, read about it <a href="http://blogs.msdn.com/b/slmperf/archive/2011/06/21/webclient-change-for-mango-how-it-impacts-your-application.aspx">here</a></li>    <li>When your list(in pivot/pano) is being populated, if you want to display a progress bar use the <a href="http://www.jeff.wilcox.name/2010/08/performanceprogressbar/">high performance progress bar</a> </li>    <li>Sometimes you bind the list to an observable collection. In that case, Add items to the UI thread in batches every some miliseconds (example add 2 items every 20ms). This keeps the UI thread free for input from the user, avoiding stutters and delays, giving the perception of performance. This is much better than adding all 20 items in one go, drawing 20 items straight on the UI thread will keep it busy and wont take in the input from user, example the flick gesture for scroll. <a title="http://blogs.msdn.com/b/rohantha/archive/2010/09/12/silverlight-wp7-list-scroll-with-items-as-image-description-from-web-bing-image-search.aspx" href="http://blogs.msdn.com/b/rohantha/archive/2010/09/12/silverlight-wp7-list-scroll-with-items-as-image-description-from-web-bing-image-search.aspx">BingImageSearch</a> is an example of one such application. </li>    <li>Peter has a good design example, where he <b>stops loading the items if the list is scrolling</b>. He elaborates about it in his blog on <a href="http://blogs.msdn.com/b/ptorr/archive/2010/10/12/procrastination-ftw-lazylistbox-should-improve-your-scrolling-performance-and-responsiveness.aspx">LazyListBox</a> </li> </ul>  <p>Finally, we are incorporating all the feedback into the platform and your comments/feedback/questions are appreciated.</p>  <p>Thanks</p>  <p>Silverlight Windows Phone 7 Perfomance Team </p>]]></content:encoded>
    </item>
  </channel>
</rss>