Fix IsInVisualTree method works with Popups.

IsInVisualTree method can't works with Popups.
This patch is fix that behavior.