title: Ability to get list of ListView items from checked items in WPF/C#?
body: <p>I have a list view of two columns. First column is a checkbox and second column is a server value. I want to essentially get a list of all servernames that have a corresponding checkbox in that row after I click a button. How is this possible? Below I was able to get the data bound successfully from my server model and put a checkbox in the first column, but I am stuck.</p>
  <p>I am attempting to follow the MVVM pattern, so I have a view-model class that I ideally want to handle this logic and then pass it along after the checked server names are stored in some collection.</p>
  <h1>XAML Code</h1>
  <pre><code>&lt;ListView ItemsSource=&quot;{Binding Servers}&quot; Margin=&quot;8,30,10,68&quot;&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Width=&quot;90&quot; Header=&quot;Select For Sync&quot;&gt;
                  &lt;GridViewColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;CheckBox Tag=&quot;{Binding ID}&quot; Checked=&quot;CheckBox_Checked&quot; Unchecked=&quot;CheckBox_Unchecked&quot; IsChecked=&quot;{Binding RelativeSource={RelativeSource AncestorType={x:Type ListViewItem}}, Path=IsSelected}&quot;/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/GridViewColumn.CellTemplate&gt;
              &lt;/GridViewColumn&gt;
              &lt;GridViewColumn Width=&quot;280&quot; Header=&quot;Pad Name&quot;  
                              DisplayMemberBinding=&quot;{Binding NodeName}&quot; /&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>