title: How to disable a button if no items are selected in a ListView
body: <p>I have a <code>ListView</code> Contained in a UserControl I would like to disabled a button when no items are selected in the UserControl, would it be the right way to do it? So far, it doesn't disable, it just stays enable all the way.
  I've included the xaml code.</p>
  
  <p>searchAccountUserControl is the UserControl name property in the xaml.
  And AccountListView is the <code>ListView</code> name property in the userControl xaml.</p>
  
  <pre><code>&lt;Button Content="Debit" IsEnabled="true" HorizontalAlignment="Left" Margin="18,175,0,0" Name="DebitButton" Width="128" Grid.Column="1" Height="32" VerticalAlignment="Top" Click="DebitButton_Click"&gt;
          &lt;Button.Style&gt;
              &lt;Style TargetType="Button"&gt;
                  &lt;Style.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding ElementName=searchAccountUserControl.AccountListView, Path=SelectedValue}" Value="{x:Null}" &gt;
                          &lt;Setter Property="Button.IsEnabled" Value="false"/&gt;
                      &lt;/DataTrigger&gt;
                  &lt;/Style.Triggers&gt;
              &lt;/Style&gt;
          &lt;/Button.Style&gt;
      &lt;/Button&gt;
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>Finally i've used : </p>
  
  <p>in my ViewModel : </p>
  
  <pre><code>private bool _isSelected;
  public bool IsSelected { get { return _isSelected; } 
  set { _isSelected = _account.View.CurrentItem != null;       
  PropertyChanged.SetPropertyAndRaiseEvent(this, ref _isSelected, value,  
  ReflectionUtility.GetPropertyName(() =&gt; IsSelected)); } } 
  </code></pre>
  
  <p>And then Use isEnabled = "{Binding Path=IsSelected}" in the xaml.</p>