none
Window contents are not collapsed on resizing?

    Question

  • Hi,

      I have a window with SizeToContent="Height".
    1. I have a button on my window, which when clicked makes the Visibility of another control to Collapsed becase of which Window Height decreases as expected.

    But when I resize the window, and perform step 1, window height remains in same size rather than shrinking and the content which has collapsed has left the empty space which is causing the window to look ugly.

    Is this a bug in WPF or is there a solution for this?
    Thursday, April 30, 2009 5:20 AM

Answers

  • Hi narmishaba.
    When you manually resize a window, you are actually setting the SizeToContent to SizeToContent.Manual.
    Add a breakpoint and put a watch on the SizeToContent property and you will see that they are different if you have resized or not.
    Its logical that you cannot resize AND have SizeToContent= SizeToContent.Height.
    Either set ResizeMode to NoResize, or set the SizeToContent back to Height where needed.
    /Henke
    • Proposed as answer by Henke Andersson Thursday, April 30, 2009 6:32 AM
    • Marked as answer by Tao Liang Tuesday, May 05, 2009 2:21 AM
    Thursday, April 30, 2009 6:32 AM

All replies

  • Hi,

    post a sample code to demonstrate the issue

    Vineeth
    Thursday, April 30, 2009 5:34 AM
  • Hi narmishaba.
    When you manually resize a window, you are actually setting the SizeToContent to SizeToContent.Manual.
    Add a breakpoint and put a watch on the SizeToContent property and you will see that they are different if you have resized or not.
    Its logical that you cannot resize AND have SizeToContent= SizeToContent.Height.
    Either set ResizeMode to NoResize, or set the SizeToContent back to Height where needed.
    /Henke
    • Proposed as answer by Henke Andersson Thursday, April 30, 2009 6:32 AM
    • Marked as answer by Tao Liang Tuesday, May 05, 2009 2:21 AM
    Thursday, April 30, 2009 6:32 AM
  • Hi Henke,


    You are correct in your analysis. Your solution greatly helped. I changed back SizeToContent=Height.

    Thanks.
    Thursday, April 30, 2009 6:47 AM