private void btnPreset_Click(object sender, RoutedEventArgs e) { try { if (_presetPopupChild == null) { _presetPopupChild = new GradientStopsPreset(); _presetPopupChild.ParentPopup = presetPopup; presetPopup.Child = _presetPopupChild; } if (this.ParentPopup != null) // it should never be null { this.ParentPopup.StaysOpen = true; } presetPopup.Placement = PlacementMode.Relative; presetPopup.PlacementTarget = this; presetPopup.VerticalOffset = 0; presetPopup.HorizontalOffset = this.ActualWidth + 5; presetPopup.IsOpen = true; } catch (Exception ex) { MessageBox.Show(ex.ToString(), TITLE, MessageBoxButton.OK, MessageBoxImage.Error); } }