WPF - Prevent Autoresize of ListBox on new Databinding?
I currently have a window with a ListBox within in. The ListBox shows the results from a search.
The开发者_如何学运维 problem I currently have is that when a search is performed and enough items are added to the ListBox, the ListBox expands vertically and forces the form to expand vertically as well.
I know I can fix this with a maxheight, but I don't want to limit the size of the form to the user, only to the program at runtime.
Is there a way I can tell the ListBox to not automatically expand or only expand when the user resizes the form?
My apologies... I've sorted out the problem. I'd mistakenly set Window.SizeToContent = "Height".
Problem solved.
Just put it in a Grid. Unless the window is set to automatically size (SizeToContent="..."), then this should work.
<Grid>
<ListBox x:Name="lstSomeData"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</Grid>
精彩评论