title: WPF - Do not show Context menu when ListView is empty
body: <p>I have a ContextMenu bind to ListView, but I don't want to be the menu shown when the ListView is empty. I tried direct binding to element, tried binding using FindAncestor, but none of these works and the menu is always shown when I click right mouse button in the ListView.
  What would be the correct binding?</p>
  
  <pre><code>&lt;Grid&gt;
  &lt;ListView x:Name="loginListView" ItemsSource="{Binding Logins}"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Width="140" Header="Login" DisplayMemberBinding="{Binding Login}"/&gt;
              &lt;GridViewColumn Width="140" Header="Password" DisplayMemberBinding="{Binding Password}" /&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  
      &lt;ListView.ContextMenu&gt;
          &lt;ContextMenu&gt;
              &lt;MenuItem 
                  Header="Delete login" 
                  Visibility="{Binding ElementName=loginListView, Path=Items.Count, Converter={StaticResource VisibilityConverter}}"/&gt;
          &lt;/ContextMenu&gt;
      &lt;/ListView.ContextMenu&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>public class visibilityConverter: IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          if ((int)value &gt; 0)
          {
              return true;
          }
          else
          {
              return false;
          }
      }
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }                
  }
  </code></pre>
  
  <p>Thanks in advance!</p>