Question

I need to fit the window's width and height to its content. I'm aware of existance of SizeToClient property of Window, however, if one chooses WidthAndHeight as the value of SizeToClient, window events are fired in invalid way, such that several components raise an exception during Loaded event: "Hwnd of zero is not valid" (for example GlassWindow's SetAeroGlassTransparency from Windows API CodePack).

Is there a workaround? I may calculate the window size manually, but I do not know, how to retrieve the window's chrome sizes (in other words, the real window's content margin sizes).

Details of WPF bug

Best regards -- Spook.

Was it helpful?

Solution

You could use SystemParameters to determine the size of the chrome. For example, SystemParameters.CaptionHeight.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top