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 8406159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:01:34+00:00 2026-06-09T23:01:34+00:00

I have WPF datagrid with multiple selections (the model has property IsSelected…) and it

  • 0

I have WPF datagrid with multiple selections (the model has property IsSelected…) and it works fine, but when I start the program, I have to click on the table first, and after that, multiple selection works. When I first click on the table, it selects the item under the cursor (if I have pressed shift, it selects the item too, but it does not do multiple selections).

I supposed it can be because of datagrid is not focused, but when I do datagrid.Focus() on the loaded window, it doesn’t work either. What should I do?

WPF DataGrid code:

<DataGrid x:Name="datagrid" AutoGenerateColumns="False" Height="Auto" VerticalAlignment="Stretch" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" Margin="3"
          CanUserAddRows="False" CanUserDeleteRows="False" 
          ItemsSource="{Binding Path=Items}" SelectedItem="{Binding Path=SelectedItem}" IsSynchronizedWithCurrentItem="True"
          SelectedIndex="{Binding Path=SelectedIndex}" SelectionMode="Extended" SelectionUnit="FullRow" EnableColumnVirtualization="False" EnableRowVirtualization="False">
    <DataGrid.Columns>
        <DataGridTextColumn Header="{Binding CodebookUnitsUnitTable, Source={StaticResource Texts}}" Binding="{Binding Path=Unit}" Width="*" IsReadOnly="True"/>
        <DataGridTextColumn Header="{Binding CodebookUnitsDescriptionTable, Source={StaticResource Texts}}" Binding="{Binding Path=Description}" Width="5*" IsReadOnly="True"/>
    </DataGrid.Columns>
    <DataGrid.CommandBindings>
        <CommandBinding Command="SelectAll" Executed="CommandBinding_Executed"/>
    </DataGrid.CommandBindings>
    <DataGrid.ContextMenu>
        <ContextMenu>
            <MenuItem Header="{Binding CodebookContextMenuNewItem, Source={StaticResource Texts}}" Command="{Binding NewItemCommand}">
                <MenuItem.Icon>
                    <myComponents:AutoGreyableImage Height="20" Margin="0,-1,0,0" Width="20" Source="../Icons/Small/INovySM.gif" Stretch="None" RenderOptions.BitmapScalingMode="NearestNeighbor" RenderOptions.EdgeMode="Aliased"/>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </DataGrid.ContextMenu>
    <DataGrid.InputBindings>
        <KeyBinding Command="{Binding DeleteCommand}" Key="Delete"/>
    </DataGrid.InputBindings>
</DataGrid>
  • 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-09T23:01:36+00:00Added an answer on June 9, 2026 at 11:01 pm

    The solution is set focused on the first row, not only on DataGrid.

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

Sidebar

Related Questions

I am using a WPF DataGrid and I have the IsSelected property of the
I have a WPF datagrid and it works great but I notice some sort
I have a wpf application using caliburn.micro. It has a datagrid and a combobox.
I have a WPF DataGrid that has another datagrid declared within the RowDetailsTemplate; <DataGrid
I have a WPF DataGrid which has a DataTable as its ItemsSource . The
I have a wpf datagrid that has it's columns generated dynamically in code and
I have a WPF DataGrid UserControl with enum property. public List<myEnum> dataList = new
I have a WPF DataGrid templatecolumn that has a DataTemplate for an AutoCompleteBox from
I have a WPF DataGrid which has an AlternatingRowBackground brush. It's configured to color
I have a WPF DataGrid that increases in height when I add data to

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.