Ideas
Get the contents of the parent form, put it in a container, and put a translucent layer in the container. Assigns the entire container to the contents of the parent form.
Reverse operation when closed.
Code
When the message window pops up
1 /// <summary>2 ///pop-up message box3 /// </summary>4 /// <param name= "message" >message</param>5 /// <param name= "owner" >parent Form</param>6 Public Static voidShowDialog (stringmessage, Window owner)7 {8 //Masking Board9Grid layer =NewGrid () {Background =NewSolidColorBrush (Color.FromArgb ( -,0,0,0)) };Ten //parent form's original content OneUIElement original = owner. Content asUIElement; AOwner. Content =NULL; - //Container Grid -Grid container =NewGrid (); theContainer. Children.add (original);//put the original content -Container. Children.add (layer);//put a layer of masks on top - //assign the container containing the original content and mask to the parent form -Owner. Content =container; + - //pop-up message box +MessageBox box =NewMessageBox () {Owner =owner}; ABox.tbc_message. Text =message; at box. ShowDialog (); -}
When the message box is closed
1 /// <summary>2 ///form Close Event3 /// </summary>4 Private voidWindow_closed (Objectsender, EventArgs e)5 {6 //Container Grid7Grid Grid = This. Owner.content asGrid;8 //parent form's original content9UIElement original = Visualtreehelper.getchild (grid,0) asUIElement;Ten //Remove the original contents of the parent form in the container grid One grid. Children.remove (original); A //Assign to parent form - This. Owner.content =original; -}
SOURCE Download: Messageboxwithlayer.zip
WPF popup message box with mask