Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you know if your WPF control is being rendered?

Tags:

wpf

I have 2 tab items. In tab No.1 I have a control which corresponds to window resize event and need to call PointToScreen().

The problem is Tab no 2 is active and I resize the window, the control in tab no.1 reacts and fail because its' visual is not being rendered and I get "This Visual is not connected to a PresentationSource" exception.

Do you know how to check this case before I call PointoScreen ?

Thanks Ariel

like image 295
ArielBH Avatar asked Dec 24 '08 16:12

ArielBH


1 Answers

You can check "IsVisible" -- This corresponds, not as a shortcut for comparing the visibility property, but also tells you if the thing is being rendered on the screen. I'm not entirely sure how how this plays into virtualization of UIElements, but I think it is correctly aware of those scenarios.

like image 92
Dominic Hopton Avatar answered Sep 28 '22 06:09

Dominic Hopton