I want to have my window size to the items in the listbox. The listbox contains variable lenght strings (20 to 120 chars). When I scroll the listbox and longer strings in the listbox scroll off the display the listbox shrinks and my window shrinks with it. How can I keep my window size fixed as the user scrolls and yet still have the window initially size to content. You know, cake and eat it too.

I have, on occasion, had the requirement that a window size to fit its content initially, then keep the size fixed unless explicitly resized. Typically, I would just hook the window's ContentRendered event, and clear out the SizeToContent property in the event handler (and also unhook the event). This ensures that layout has fully completed, and the window has been shown and its bounds fully computed by the time you revert to a fixed size.

This isn't the best solution in the world, and it breaks down in cases where your content isn't fully available when the ContentRendered event fires. The most likely example I can think of would be if data in your view model is not yet available, and, consequently, your view is not fully populated yet. This may not be an issue for you--it depends on your design and whether you are doing any deferred/async data loading. But it works in simpler scenarios, and it has the virtue of being simple to implement.