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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:35:43+00:00 2026-05-16T07:35:43+00:00

I have a DataGrid (the official one) with SelectionUnit=Cell . When the user selects

  • 0

I have a DataGrid (the official one) with SelectionUnit="Cell". When the user selects a cell, I’d like to show the row details for the corresponding row. This is apparently not the default behavior, and I can’t seem to figure out how to accomplish this.

Here’s my XAML:

<UserControl x:Class="View.Test"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../AppResources.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <DataGrid AutoGenerateColumns="False" 
                ItemsSource="{Binding Path=Fields}" 
                BorderBrush="Transparent" 
                HeadersVisibility="Column"
                SelectionMode="Single"
                SelectionUnit="Cell"
                CanUserAddRows="False"
                CanUserDeleteRows="False"
                CanUserSortColumns="False"
                IsTextSearchEnabled="True"
                x:Name="EntryGrid"
                >
            <DataGrid.Columns>
                <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" Width="Auto" IsReadOnly="True"/>
                <DataGridTemplateColumn Header="Value" Width="Auto" x:Name="valueColumn" MinWidth="60" MaxWidth="90">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=DisplayValue}" TextTrimming="CharacterEllipsis" ToolTip="{Binding Path=Text, RelativeSource={RelativeSource Self}}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <DockPanel>
                                <ComboBox TabIndex="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" SelectedValue="{Binding Path=Value, UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Value" ItemsSource="{Binding Path=FieldOptions}" Visibility="{Binding Path=FieldOptions, Converter={StaticResource EmptyCollectionIsInvisibleConverter}}" />
                                <TextBox TabIndex="2" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Stretch" Visibility="{Binding Path=FieldOptions, Converter={StaticResource NonEmptyCollectionIsInvisibleConverter}}"/>
                            </DockPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Description" IsReadOnly="True" Width="*" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Description}" TextWrapping="Wrap" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Path=Help}" />
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>
        </DataGrid>
    </Grid>
</UserControl>
  • 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-16T07:35:44+00:00Added an answer on May 16, 2026 at 7:35 am

    You can set the SelectionUnit to FullRow

    SelectionUnit="FullRow"
    

    or you can handle the selection event and set the visibility on event handling.

        private void EntryGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            foreach (var cell in e.AddedCells)
            ((DataGridRow)EntryGrid.ItemContainerGenerator.ContainerFromItem(cell.Item)).DetailsVisibility = System.Windows.Visibility.Visible;
            foreach (var cell in e.RemovedCells)
                ((DataGridRow)EntryGrid.ItemContainerGenerator.ContainerFromItem(cell.Item)).DetailsVisibility = System.Windows.Visibility.Collapsed;
        }
    

    Insert disparaging remarks about the WPF DataGrid here.

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

Sidebar

Related Questions

i have datagrid in my project which i bind my attributes collection like this:
I have this datagrid view: Now when the first row is double clicked i
I have a DataGrid with a CheckBox column. I show a popup if the
I have a DataGrid that represents layers - each row is an image on
I have a DataGrid a user can add items to by entering data in
I have a datagrid bound to an ObservableCollection, and what I'd like to do
I have Datagrid which is bound to my Database <WpfToolkit:DataGrid Name=DataGrid1 Grid.Row=1 ItemsSource={Binding Path=MainSearchBinding}
I have Datagrid which is clicking by mouse in each row is showing data
I have datagrid. the source for this datagrid is a url that returns n
I have datagrid and inside this grid have template field. I add Header text

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.