title: WPF: ListView Cannot Get Focus when Click in Blank Area
body: <p>ListView can only get focus when clicking on listview items. When clicking on blank area, which is also part of the listview, focus cannot be got.</p>
  
  <p>Example:</p>
  
  <pre><code>      &lt;Grid&gt;
              &lt;ListView x:Name="lv" 
                        GotFocus="Lv_OnGotFocus"
                        LostFocus="Lv_OnLostFocus"
                        MouseEnter="Lv_OnMouseEnter"&gt;
                  &lt;ListViewItem&gt;Foo&lt;/ListViewItem&gt;
                  &lt;ListViewItem&gt;Bar&lt;/ListViewItem&gt;
              &lt;/ListView&gt;
          &lt;/Grid&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OoNS1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OoNS1.png" alt="Mouse Move In Area"></a></p>
  
  <p>In code above I bind event handler to the listview not the listview item.</p>
  
  <ul>
  <li>When cursor moves in the blank area, <em>Lv_OnMouseEnter</em> handler is triggered, which indicate the blank area are also part of listview.</li>
  <li>When clicking in the blank area, <em>Lv_OnGotFocus</em> is not triggered. Focus not got.</li>
  <li>When clicking on any listview item, <em>Lv_OnGotFocus</em> is triggered. Focus got.</li>
  <li>It's even the SAME, when <em>Lv_OnGotFocus</em> handler was moved to outter <strong>Grid</strong>.</li>
  </ul>
  
  <p>How to get focus when any part of listview is clicked ?</p>
  
  <blockquote>
    <p>WHY I need focus on blank area?</p>
    
    <p>I'm implementing file Copy &amp; Paste function in the listview, in which listview items bind to files on disk. Paste action is triggered by a <em>PreviewKeyDown</em> handler attached to the listview, in which <em>Ctrl + V</em> key press is checked.</p>
    
    <p>If a folder is empty, the listview is empty. Thus <em>PreviewKeyDown</em> handler cannot be triggered , as the <em>Lv_OnGotFocus</em> handler, in a empty folder,  Whereas copying file into empty folder meant to be work.</p>
  </blockquote>