title: How can you programatically scroll a WrapGrid to a specific item within its ItemSource in a Windows Store App?
body: <p>I have the following:</p>
  
  <pre><code>&lt;GridView.ItemsPanel&gt;
      &lt;ItemsPanelTemplate&gt;
          &lt;WrapGrid Orientation="Vertical"
                    MaximumRowsOrColumns="10" /&gt;
      &lt;/ItemsPanelTemplate&gt;
  &lt;/GridView.ItemsPanel&gt;
  </code></pre>
  
  <p>I would like to scroll to a specific item, but can't find out how.</p>
  
  <p>So far I have:</p>
  
  <pre><code>int itemIndex = ...;
  var scrollBar = TheGridView.GetFirstDescendantOfType&lt;ScrollViewer&gt;();
  scrollBar.ScrollToHorizontalOffset((double)itemIndex / NumberRows);
  </code></pre>
  
  <p>... but that feels oddly hacky, and means that I have to programatically calculate the number of rows.</p>
  
  <pre><code>const int IndividualItemHeight = /* Nasty Hard-Coded thing */;
  numberOfRows = (int)((TheGridView.ActualHeight - TheGridView.Padding.Top -
                        TheGridView.Padding.Bottom) / IndividualItemHeight);
  </code></pre>
  
  <p>... which is even more hacky.</p>
  
  <p>There must be a better way. Any help much appreciated!</p>