title: How to force focus on a XAML ListView for Windows 10 apps (UWP)?
body: <p>I have a pivot control for which i am passing data using ItemSource property. I am also using a data template to populate the Pivot Items.</p>
  
  <p>The data template has a listview inside.</p>
  
  <pre><code>&lt;DataTemplate ..... &gt;
  
  &lt;ListView ....&gt;&lt;/ListView&gt;
  
  &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>I am trying to attach keyboard events to the ListView in the page. Like scroll to top using Home key and scroll to bottom using End key.</p>
  
  <p>Since the ListView is inside DataTemplate, I am unable to hookup a Keyboard event at compile time.</p>
  
  <p>Approaches taken to overcome this:</p>
  
  <p>1) Using KeyDown property in Xaml control</p>
  
  <pre><code>Result: Too much delay for the event to trigger
  </code></pre>
  
  <p>2) Using VisualTree</p>
  
  <pre><code>Result: Traversing creates lot of overhead.
  </code></pre>
  
  <p>3) Using ListView Loaded event</p>
  
  <pre><code>Result: Called only once
  </code></pre>
  
  <p>Best solution taken so far:</p>
  
  <p>1) Attaching the keyboard event for GotFocus property of the ListView.</p>
  
  <p><strong>But I wanted to force focus on the Listview as the page loads. Also, when I change pivot item, it should automatically force focus on the new ListView.</strong></p>