2

i have a wpf datagrid with several defined DataGridTextColumns. When i bind long strings (100 characters) the bounded column grows correctly depending on content. When the datacontext change and the bounded strings gets shorter (10 characters) the column width dont't shrink.

If the datagrid generates the columns (AutoGenerateColumn="True") the column width adjust correctly when the datacontext change.

How can i achieve my defined columns to adjust depending on her content?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Jana Hehr
  • 21
  • 1
  • Have you looked here: http://stackoverflow.com/questions/560581/how-to-autosize-and-right-align-gridviewcolumn-data-in-wpf – Silvermind Mar 16 '12 at 10:32
  • @Silvermind that link is GridView and I think it also suffers from not giving back space. – paparazzo Mar 16 '12 at 13:45
  • I have seen this problem where you don't get space back. Hopefully someone will have an answer for you. What I do is use TextBlocks with wrap and a hard column width. – paparazzo Mar 16 '12 at 13:47
  • Did you explicitly set the Width to "Auto", just asking. – Silvermind Mar 16 '12 at 14:36
  • @Silvermind How would you set the width of DataGridColumn to Auto if AutoGenerateColumns = "True" ? – paparazzo Mar 16 '12 at 20:42
  • 1
    @Blam It's just there `` however i tested it already and it does not work resizing back. – Silvermind Mar 16 '12 at 20:49
  • Your question looks like this question btw: http://stackoverflow.com/questions/4725724/datagrid-column-widths-not-updating-on-itemssource-change – Silvermind Mar 16 '12 at 20:52

0 Answers0