title: WPF ListView Selection inside a treeview I Need to get all the selected ListView Items(when Holding CTRL key) in selection changed event
body: <p>New to WPF</p>
  
  <p>This is Xaml code <strong>Need to Get All Selected ListView Items onto selection changed event</strong></p>
  
  <p>I Tried to work with Multiselecttreeview nuget but the problem is both parent and child are same in that case .
  Also TreeviewEX does the same .Any help would be great.</p>
  
  <pre><code>                &lt;Window x:Class="DemoApps.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                      xmlns:local="clr-namespace:DemoApps"
                      mc:Ignorable="d"
                      Title="MainWindow" Height="350" Width="525"&gt;
                  &lt;Grid&gt;
  
                      &lt;TreeView x:Name="TreeViewList" Loaded="TreeViewList_Loaded"&gt;
  
                          &lt;TreeView.ItemTemplate&gt;
                              &lt;HierarchicalDataTemplate DataType="{x:Type local:Group}" ItemsSource="{Binding Users}" &gt;
                                  &lt;Grid Width="200" Height="auto"&gt;
                                      &lt;StackPanel&gt;
                                          &lt;TextBlock Text="{Binding GroupName}"/&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/Grid&gt;
  
                                  &lt;HierarchicalDataTemplate.ItemTemplate&gt;
                                      &lt;DataTemplate DataType="{x:Type local:User}"&gt;
                                          &lt;ListView SelectionMode="Extended" SelectionChanged="ListView_SelectionChanged"&gt;
                                              &lt;Grid Width="150" Height="20"&gt;
                                                  &lt;StackPanel&gt;
                                                      &lt;TextBlock Text="{Binding UserName}" /&gt;
                                                  &lt;/StackPanel&gt;
                                              &lt;/Grid&gt;
                                          &lt;/ListView&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/HierarchicalDataTemplate.ItemTemplate&gt;
                              &lt;/HierarchicalDataTemplate&gt;
  
  
                          &lt;/TreeView.ItemTemplate&gt;
                          &lt;TreeView.ItemContainerStyle&gt;
                              &lt;Style TargetType="TreeViewItem"&gt;
  
                                  &lt;Setter Property="IsSelected" Value="{Binding IsSelected}" /&gt;
                                  &lt;Setter Property="IsExpanded" Value="{Binding IsExpanded}" /&gt;
                              &lt;/Style&gt;
                          &lt;/TreeView.ItemContainerStyle&gt;
                      &lt;/TreeView&gt;
  
                  &lt;/Grid&gt;
              &lt;/Window&gt;
  </code></pre>
  
  <p>This is my code behind</p>
  
  <pre><code>                using System.Collections.ObjectModel;
              using System.ComponentModel;
              using System.Windows;
              using System.Windows.Controls;
  
              namespace DemoApps
              {
                  /// &lt;summary&gt;
                  /// Interaction logic for MainWindow.xaml
                  /// &lt;/summary&gt;
                  public partial class MainWindow : Window
                  {
  
                      public ObservableCollection&lt;Group&gt; GroupData { get; set; }
                      public MainWindow()
                      {
                          InitializeComponent();
  
                          GroupData = GetDummyData();
  
                      }
  
                      private ObservableCollection&lt;Group&gt; GetDummyData()
                      {
                          var _group = new ObservableCollection&lt;Group&gt;();
  
                          for (int i = 0; i &lt; 20; i++)
                          {
                              _group.Add(new Group
                              {
  
                                  GroupName = "Group name" + i,
                                  Users = GetDummyUsers(i)
  
                              });
                          }
                          return _group;
                      }
  
                      private ObservableCollection&lt;User&gt; GetDummyUsers(int i)
                      {
                          var _user = new ObservableCollection&lt;User&gt;();
                          for (int j = 0; j &lt; 10; j++)
                          {
                              _user.Add(new User
                              {
  
                                  UserName = "User " + i + "-" + j
                              });
  
                          }
                          return _user;
  
                      }
  
                      private void TreeViewList_Loaded(object sender, RoutedEventArgs e)
                      {
                          TreeViewList.ItemsSource = GroupData;
                      }
  
                      private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
                      {
                          //Need to get all selected items from List View.
                          //Here i need to get the selected items
                      }
                  }
  
                  public class Group : TreeViewItemBase
                  {
  
                      public string GroupName { get; set; }
  
                      public ObservableCollection&lt;User&gt; Users { get; set; }
                  }
  
                  public class User
                  {
  
                      public string UserName { get; set; }
                  }
  
                  public class TreeViewItemBase : INotifyPropertyChanged
                  {
                      private bool isSelected;
                      public bool IsSelected
                      {
                          get { return this.isSelected; }
                          set
                          {
  
                              this.isSelected = value;
                              NotifyPropertyChanged("IsSelected");
  
                          }
                      }
  
                      private bool isExpanded;
                      public bool IsExpanded
                      {
                          get { return this.isExpanded; }
                          set
                          {
  
                              this.isExpanded = value;
                              NotifyPropertyChanged("IsExpanded");
                          }
                      }
  
  
  
  
                      public event PropertyChangedEventHandler PropertyChanged;
  
                      public void NotifyPropertyChanged(string propName)
                      {
                          if (this.PropertyChanged != null)
                              this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
                      }
  
                  }
              }
  </code></pre>
  
  <p>How can get all the selected Items of ListView into Selection changed event </p>