Background:
I have a DataGrid with multiple TextColumns. One column is read-only, and bound to the text of a TextBox that’s outside of the DataGrid. This TextBox is a multi-line textbox, meaning that AcceptsReturn = true and TextWrapping = Wrap.
Problem:
When a user enters multiple lines in the multi-line TextBox, the bound DataGridCell (and its row) vertically grow so all the text appears.
Questions:
- Is there a way to get a vertical scrollbar to appear within the cell, when multiple lines should appear?
- Generally, what are other techniques to circumvent the growth of a DataGridCell, and its row, due to multi-line content?
Research:
I know I can prevent a DataGridRow’s growth by forcibly setting its Height. However, that doesn’t trigger a scrollbar.
And I confirmed that WordWrap is off for the TextBlock within the DataGridCell.
Thanks
I ended up being a bit flexible with my requirements and came up with this style:
By setting MaxHeight on my DataGridCellsPresenters, I can trigger vertical scrollbars without directly interfering with row heights. And I can apply it consistently across my application, rather than per column.