In my application, I have a outlook bar which has some menu items. On click event of mneu Item I want to traverse the visual tree upto main Window. For normal view of Outlook bar it is working properly but for collapsed view of outlook bar when I click menu item it traverse till PopUpRoot control only. Parent of this control returns null.
var parent = VisualTreeHelper.GetParent(this);
while (!(parent is Window))
{
parent = VisualTreeHelper.GetParent(parent);
}