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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:20:02+00:00 2026-05-18T12:20:02+00:00

I am experiencing some strange behavior in my datagrid when I have a second

  • 0

I am experiencing some strange behavior in my datagrid when I have a second datagrid as a rowdetailstemplate. The main datagrid is bound to my collection of items, and the details datagrid is bound to a collection of subitems contained by an item. Now all of this renders perfectly, but when I want to click on a cell in the SubItemsGrid directly, it first selects the first cell of the row in the main grid in which the SubItemsGrid is contained. I have to click a second time to get to the cell I want to select.

Has anyone experencied this as well? And if so, is there a workaround?

This is my mark-up (partially):

<DataGrid x:Name="ItemGrid" ItemsSource="{Binding Path=Items}" AutoGenerateColumns="False" SelectionUnit="Cell"
          RowDetailsVisibilityMode="Visible" CanUserResizeRows="False" AreRowDetailsFrozen="False" VerticalAlignment="Top"
          CanUserAddRows="False" CanUserDeleteRows="False" VerticalScrollBarVisibility="Hidden">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Column1" Binding="{Binding Path=ID}" Width="350"/>
        <DataGridTextColumn Header="Column2" Binding="{Binding Path=Name}" Width="80"/>
        <DataGridTextColumn Header="Column3" Binding="{Binding Path=Description}" Width="80"/>
    </DataGrid.Columns>
    <DataGrid.RowDetailsTemplate>
        <DataTemplate>
            <DataGrid x:Name="SubItemsGrid" ItemsSource="{Binding Path=SubItems}" AutoGenerateColumns="False"
                      SelectionUnit="Cell" HeadersVisibility="None" Margin="50,0,0,0" VerticalAlignment="Top" CanUserAddRows="False" 
                      CanUserResizeRows="False" CanUserDeleteRows="False" BorderThickness="0">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Column1" Binding="{Binding Path=Name}" Width="300" />
                    <DataGridTextColumn Header="Column2" Binding="{Binding Path=Description}" Width="80"/>
                    <!-- Etc.--> 

—EDIT—

Ok, I came up with the idea to handle the mouse-up event on the SubItemsGrid, and then set the focus to the SubItemsGrid in code, like this:

private void SubItemsGrid_MouseUp(object sender, MouseButtonEventArgs e)
{
   DataGrid selectedGrid = sender as DataGrid;
   if (selectedGrid != null)
   {
       selectedGrid.Focus()
   }
}

Debugging show that the ‘Focus’ method gets called on the right grid, but I am not getting any visual results. I get the feeling I am very close to the solution however. Anyone?

  • 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-18T12:20:02+00:00Added an answer on May 18, 2026 at 12:20 pm

    I fixed this by catching the ‘SelectedCellsChanged’ event of the SubItemsGrid. In the handler I called ‘BeginEdit()’ on the grid that raised the event. This indeed put the focus on the clicked cell directly, but also put the cell in edit mode. That’s why I called CancelEdit() directly after. This will keep the focus on the cell, but not in edit mode.

    private void SubItemsGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
    {
       DataGrid selectedGrid = sender as DataGrid;
       if (selectedGrid != null)
       {
           selectedGrid.BeginEdit();
           selectedGrid.CancelEdit();
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experiencing some strange behavior with SQL Server CE 3.5 SP2. I have
I'm experiencing some strange behavior for which I can't find any documented knowledge. Here's
I'm experiencing some strange behavior with a project i'm working on: http://daft.net76.net/yah/ When you
I am experiencing some strange behavior with OSQL, and would appreciate any help. I
I experiencing a strange behavior of C#. Its some thing like this.. var date
I am experiencing strange behavior using git stash, I have two branches v0 and
I am working on an Orbited -powered website and I'm experiencing some annoying behavior
We just started using jCarousel with our application and we're experiencing some strange UI
I'm experiencing some strange behaviour when using a stylus with swing. I am interpreting
I have the following class in a Windows Service that is experiencing some vary

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.