public void InitMessageBox() { //Window parentWindow = Window.GetWindow(this); //var childElements = ((Panel)parentWindow.Content).Children; CustomMessageBox deletePopup = new CustomMessageBox(); deletePopup.Name = "MsgBoxDialogControl"; deletePopup.CustomMessageBoxType = CustomMessageBox.CustomMessageBoxTypeEnum.Info; deletePopup.DataContext = this.DataContext; deletePopup.SetBinding(CustomMessageBox.MessageBoxOkCommandProperty, new Binding("MessageBoxInfoConfirmButtonCommand")); deletePopup.SetBinding(CustomMessageBox.MessageBoxVisibilityProperty, new Binding("MessageBoxInfoVisibility")); deletePopup.SetBinding(CustomMessageBox.MessageBoxTextProperty, new Binding("MessageBoxInfoText")); deletePopup.MessageBoxOkButtonText = Application.Current.FindResource("OK").ToString(); deletePopup.MessageBoxHeaderText = Application.Current.FindResource("MessageBoxErrorTitle").ToString(); VerificationMasterGrid.Children.Add(deletePopup); }