How can I get the parent Popup for a UIElement?
问题 I have two questions on markup below: <Popup> <Button x:Name="button"/> </Popup> Why does VisualTreeHelper.GetParent(button) return null? How can I get the parent Popup for UIElement ? 回答1: Because the Button is only added to the visual tree when the popup is being displayed. Hmm... tricky ... Edit There is an assumption in the following that your popup is defined in the XAML of UserControl so whilst its child may not be in the visual tree the popup primitive control is. Re-using some code I