WPF Auto height in code
While the question has been answered with the code-behind (as asked), here is the same solution in XAML for basic control properties who don't have "auto"
:
xmlns:sys="clr-namespace:System;assembly=mscorlib"Height="{x:Static sys:Double.NaN}"
Posting because google took me here when searching for XAML solution for a TextBox
(auto doesn't exist).