Konrad Morawski
Konrad Morawski

Reputation: 8394

How to enforce that WPF (popup) window resizes before it's visible?

I'm using a pop-up window in my WPF application. It's a borderless window with SizeToContent set to WidthAndHeight.

It resizes itself every time I show it to the user in order to accomodate for various lengths of caption on the button and the number of buttons which can vary etc.

Unfortunately, this auto-resizing is noticeable - especially when the window shrinks; it looks "jumpy" and thus sort of amateurish.

I'm never disposing of this window - just hiding and showing again - because I'd have to reattach some event handlers every time, and also repopulate a listbox (with language codes), which I'm not sure I should do.

Is there any way I could tell it to calculate the right size before it is displayed?

Upvotes: 0

Views: 785

Answers (1)

user572559
user572559

Reputation:

It must be WPF perf optimization. Calling InvalidateMeasure() beforehands might help.

Upvotes: 1

Related Questions