Reputation: 185
I have a WPF project with a DataGrid in my window and, initially, I just set its ItemsSource
to a collection of objects, and the grid auto-generated columns, based on their properties. In that stage when starting the application I, as the user, could click a cell (in the user interface) and it would allow me to select/drag-select part of the text in that cell.
Now I disabled the auto-generation of columns and defined custom columns, binding them to select properties of said objects. And now clicking a cell just selects the entire cell and its entire contents. I've looked at all DataGrid and DataGridCell properties but don't see anything which would obviously alter this behaviour.
How can I set a manually defined DataGridTextColumn
in the XAML to have the text content of its cells be partially selectable, instead of only being able to select the entire cell content?
Upvotes: 0
Views: 631
Reputation: 185
I want to thank RolandJS, his answer made me realise I probably could inspect WPF controls' properties at debug time and that led me to the Live Visual Tree, seeing all properties are the same, which led me to the binding, which was mode = one way.
So, basically, the text in DataGrid cells can only be partially selected/drag selected if the binding is in a mode that allows changing the source, because that is what you are potentially doing.
Upvotes: 0
Reputation: 1055
The DataGridTextColumn is behaving the same whether it is autogenerated or not. Maybe you are setting IsReadOnly = True. That could be one reason for it to behave like you are describing. Otherwise, you have to provide us with code and data, that is showing your case.
Upvotes: 0