title: How can I get the checked checkbox values using MVVM?
body: <p>Right now, I'm working on a WPF project.</p>
  
  <p>I have a confirmation dialog that displays a list of repeated strings that the user imported from a CSV file. </p>
  
  <p>The user can check off the repeated strings they want to add to a list (listview) and click ok. </p>
  
  <p>The problem is I'm not sure how to get the value of the checkbox items that are checked off and add them to a list. How do I know what checkbox is selected and add the selected items to a list? </p>
  
  <p>I want to do this task using MVVM and not code behind. I've seen a few examples using code behind and they still confuse me. </p>
  
  <p>I think I have to use commands but I'm not sure still how to get the selected checkbox value? </p>
  
  <p>Here's my attempt: </p>
  
  <p>Code in ViewModel: </p>
  
  <pre><code>private bool isSelected;
      public bool IsSelected
      {
  
          get
          {
  
              return isSelected;
          }
  
          set
          {
  
              isSelected = value;
              RaisePropertyChanged("IsSelected");
  
              if (IsSelected == true)
              {
  
                  foreach (var item in confirmationList.PassList)
                  {
  
                      List.Add(item);
                  }
  
                  RaisePropertyChanged(LIST);
  
              }
  
              else if (IsSelected == false)
              {
  
              }
          }
      }
  </code></pre>
  
  <p>XAML: </p>
  
  <pre><code>&lt;Grid&gt;
  &lt;ListView ItemsSource="{Binding Inventory}"&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn&gt;
                  &lt;GridViewColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                           &lt;CheckBox Content="{Binding}" IsChecked="{Binding Path=IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/GridViewColumn.CellTemplate&gt;
              &lt;/GridViewColumn&gt;
  
              &lt;GridViewColumn DisplayMemberBinding="{Binding Name}"
                              Header="Name"&gt;
              &lt;/GridViewColumn&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p></p>
  
  <p>Not sure what else to do from here to get the checked off values?</p>
  
  <p>EDIT: updated xaml to reflect look.</p>