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.
You could use SystemParameters to determine the size of the chrome. For example, SystemParameters.CaptionHeight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With