This is a migrated thread and some comments may be shown as answers.

How to select entire row on clicking the row header?

1 Answer 190 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 2
Anton asked on 13 Aug 2012, 09:58 AM
I want to select cells in grid and select rows on clicking on rows headers.
How to implement it? I've set up SelectionUnit="Cell". Now I need in selection rows on clicking on headers.

I need in the same functionality as in standard DataGrid (SelectionUnit="CellOrRowHeader").

1 Answer, 1 is accepted

Sort by
0
Anton
Top achievements
Rank 2
answered on 14 Aug 2012, 10:11 AM
Quick fix:

       private void RadGridView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            var source = e.OriginalSource as DependencyObject;
            if(source == null)
                return;

            var cell = source.FindVisualParent<GridViewCell>();
            if(cell != null)
            {
                ((RadGridView)sender).SelectionUnit = GridViewSelectionUnit.Cell;
            }
            else
            {
                var row = source.FindVisualParent<GridViewRow>();
                if(row != null)
                {
                    ((RadGridView)sender).SelectionUnit = GridViewSelectionUnit.FullRow;
                }
            }
        }
Tags
GridView
Asked by
Anton
Top achievements
Rank 2
Answers by
Anton
Top achievements
Rank 2
Share this question
or