Tony Allan

Tony Allan

  • NA
  • 71
  • 9.8k

Resize the font in a datagrid cell so it fits the cell.

Nov 19 2019 11:56 AM
In this example I have a simple DataTable with headings, 3 column and 2 Rows of data. Bound to datatable 1 (dt1). What I wish to do is have the font size of each cell to adjust to fill the cell width. No word wrapping or use of viewbox as they do not suit the overall application. I have used viewbox on the last column to demonstrate the viewbox behaviour I wish to escape. It reduces the area of the textbox in the cell meaning that you have to click exactly on the text in order to edit the cell. The behaviour I am looking for is to adjust the font size (doesn't matter how small it gets as in the final implementation the user can adjust the width of the column and so increase the font to a readable size) to fit the cell width on one line. The font size just needs to adjust to the width of the cell so as to fit in the cell no matter how small the font may become. Thank you Tony.
 
 

Attachment: C#AndXAML.zip

Answers (2)