Wpf control size to content?
问题 How do I make a WPF control to change its size according the content in it? 回答1: For most controls, you set its height and width to Auto in the XAML, and it will size to fit its content. In code, you set the width/height to double.NaN . For details, see FrameworkElement.Width, particularly the "remarks" section. 回答2: I had a problem like this whereby I had specified the width of my Window, but had the height set to Auto . The child DockPanel had it's VerticalAlignment set to Top and the