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

  • SEARCH
  • Home
  • 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 9272759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:56:36+00:00 2026-06-18T15:56:36+00:00

I want to know who are the selected items in the DataGrid (insert them

  • 0

I want to know who are the selected items in the DataGrid (insert them to the collection in the ViewModel).

When I bind to the selected item is changed only when I click on the row (1 row), but when I press ctrl + clicking it remains the first item, why is this happening and is it possible to link all selected items?

Here my DataGrid:

<DataGrid SelectedIndex="{Binding SelectedXIndex}" DataContext="{Binding XViewModel}" SelectedItem="{Binding CurrentX}" ItemsSource="{Binding ListX, Mode=TwoWay}" AutoGenerateColumns="False" >
    <DataGrid.Columns>
     ...
    </DataGrid.Columns>
</DataGrid>

In the XViewModel I have:

SelectedXIndex (int) for the selected index

CurrentX (object of class x) for the current selection

ListX – list of class x

  • 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-06-18T15:56:36+00:00Added an answer on June 18, 2026 at 3:56 pm

    The first suggestions i made did not work. I leave them just for historical reasons.

    I finally think that the problem is that what you want to do is kind of strange – or error prone. You put your bind to SelectedItem (one item) while you want to be able to select multiple.

    I would personally put no binding at all in xaml (except the ItemsSource of course) and track selection changes with the selectionChanged event in the back end code. A link with a similar problem supporting this method is found here

    Hope you find a better solution

    OLD SUGGESTIONS:

    this should solve the issue as you seem to be treating it like a single mode selection Datagrid but you do nto explicitely define it as such:

    <DataGrid SelectionMode="Single"
    

    If you want the selection mode to be multiple then you should NOT bind to SelectedIndex

    I also wonder why you have both SelectedIndex binding and SelectedItem binding. In any case just one should be needed.

    Keep just the SelectedItem binding set SelectionMode to Extended and try again

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the ComboBox.SelectionChanged event I want to know who changed the ComboBox value, the
Here is the wiki for those who want to know about Apache CXF. http://en.wikipedia.org/wiki/Apache_CXF
preferably free demo :) In other words, I want to know who uses which
In my page there are many controls and I want to know who causes
I have a static Java method, where I want to know who is its
Can I get logs based on content? Let's say I want to know who
I want to know who refers my webpage, so in my models I have:
For example I want to know who are the tallest guys in some group
This is not a code question, but about concepts. I want to know who
i want know how i can manage multiple twitter account on iOS in my

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.