static void SnoopChildPopupClosed(object sender, EventArgs e) { var popup = (Popup)sender; if (popup.Child != null) { // Cannot use 'popup' as a snoop part, since it's not // going to be in the PopupRoot's visual tree. The closest // object in the PopupRoot's tree is popup.Child: SnoopPartsRegistry.RemoveSnoopVisualTreeRoot(popup.Child); } }
private static void SnoopChildPopupOpened(object?sender, EventArgs e) { var popup = (Popup?)sender; if (popup?.Child is not null) { // Cannot use 'popup' as a snoop part, since it's not // going to be in the PopupRoot's visual tree. The closest // object in the PopupRoot's tree is popup.Child: SnoopPartsRegistry.AddSnoopVisualTreeRoot(popup.Child); } }