Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto size ElementHost to its content

I have a small WPF control that has a TextBlock with TextWrapping set to Wrap. I am trying to host this in an existing WinForms application. I have the ElementHost docked to the top of the form, and I would like to size the height of the ElementHost based on the height that the TextBlock require. Is there any way to accomplish this?

like image 204
Brian Kohrs Avatar asked Feb 25 '11 19:02

Brian Kohrs


1 Answers

The resizing mechanism of WinForms is different from WPF's.

Have you tried setting the AutoSize property of the ElementHost to true?

like image 124
Emond Avatar answered Nov 01 '22 20:11

Emond