Skip to content

PopupWindow can control the position of pop-up elements more flexibly than PopTip.

WARNING

PopupWindow may become obsolete in future versions.

cs
[TemplatePart(Name = ElementMainBorder, Type = typeof(Border))]
[TemplatePart(Name = ElementTitleBlock, Type = typeof(TextBlock))]
public class PopupWindow : System.Windows.Window

Attributes

PropertyDescriptionDefault ValueRemarks
PopupElementPopup Element
ShowTitleWhether to show the titletrue
ShowCancelWhether to show the cancel buttonfalse
ShowBorderWhether to show the borderfalse
ContentStr

Method

NameDescription
Show(FrameworkElement, bool)Display window (pop-up element, with background or not)
Show(System.Windows.Window, Point)Display window (relative window, offset coordinates)
Show(string)Show window (pop-up message)
ShowDialog(FrameworkElement, bool)Modal display window (pop-up element, whether with background)
ShowDialog(string, string title, bool)Modal display window (pop-up information, title, whether to display the cancel button)

Case

PopupWindow popup = new PopupWindow()
                {
                    MinWidth = 400,
                    Title = "Title",
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                    ShowInTaskbar = true,
                    AllowsTransparency = true,
                    WindowStyle = WindowStyle.None
                };
                TextBox txtUsername = new TextBox();
popup.PopupElement = mainStack;
popup.ShowDialog();

Released under the MIT License.