Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5984275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:21:06+00:00 2026-05-22T22:21:06+00:00

For a ListView where I can select multiple items from the list, my method

  • 0

For a ListView where I can select multiple items from the list, my method for the selected Index will be called if I’m selecting one item. But I I select more than one at a time my ‘TheSelectedIndex’ method is not being called. I want it to be called for any type of selection. zero items, 1 item ore more than 1 item. How do I set it up for that? Thank you very much!

<ListView
           SelectionMode="Multiple"
           SelectedIndex="{Binding Path="TheSelectedIndex}"
           ItemsSource="{Binding Path=Object}">
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:21:07+00:00Added an answer on May 22, 2026 at 10:21 pm

    One way to handle this is to ensure that the type to which you bind the ItemsSource property exposes an IsSelected property. This may mean wrapping that type into a custom ViewModel class that simply exposes the underlying type and adds an IsSelected property.

    Once you introduce the concept of selection state to the individual items in the bound collection, you can leverage the ListView.SelectionChanged event and some code-behind to access the view-model (assumes you’re using MVVM, which I think you are, considering your bindings):

    In XAML…

    <ListView SelectionChanged="ListView_SelectionChanged" />
    

    In code-behind…

    private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var vm = (MyViewModel)DataContext;
        var selectedItems = ((ListView)sender).SelectedItems.Cast<SomeType>();        
    
        vm.SetSelectedItems(selectedItems);
    }
    

    In view-model…

    public void SetSelectedItems(IEnumerable<SomeType> selectedItems)
    {
        /* Remove items that were previously selected but no longer are selected */
        var currentlySelectedItems = MyItems.Where(i => i.IsSelected == true);
        foreach (var previouslySelectedItem in currentlySelectedItems.Except(selectedItems))
            previouslySelectedItem.IsSelected = false;
    
        /* Set the selection state on all currently/newly selected items */
        foreach (var selectedItem in selectedItems)
            selectedItem.IsSelected = true;
    
        NotifyOfPropertyChanged(() => MyItems);
    }
    

    In SomeType, which is a view-model wrapper for each item in the collection…

    public bool IsSelected { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I make columns in Android ListView? I have this list item layout
I'm building a list of contacts, where the user can select more than one
How can i save the info from a multiple choice listview into the database?
Can you have a multicolumn listview control where one of the columns is a
How can I prevent a user from resizing GridViewColumns withing a ListView control?
I'm trying to select the first item in a ListView programmatically, but it doesn't
I want to select item in a ListView upon clicking. I also want to
I can add items to a listview this way: ListViewItem.Items.Add(Text) But how can I
Is there a way in which I can save details from a ListView that
I have a little problem with a Listview. I can load it with listview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.