views:

30

answers:

2

Hey all,

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?

Thanks,
Sonny

A: 

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>
Wonko the Sane
A: 

My apologies... I've sorted out the problem. I'd mistakenly set Window.SizeToContent = "Height".

Problem solved.

Sonny Boy
I'm glad you found your problem! I suggest you either accept your own answer or vote to have the question deleted? Regards
Andre Luus
Yeah... I have to wait 24 hours though before I can accept my own answer.
Sonny Boy