Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you display a custom UserControl as a dialog?

Tags:

c#

.net

wpf

How do you display a custom UserControl as a dialog in C#/WPF (.NET 3.5)?

like image 757
Taylor Leese Avatar asked Aug 11 '09 18:08

Taylor Leese


1 Answers

Place it in a Window and call Window.ShowDialog. (Also, add references to: PresentationCore, WindowsBase and PresentationFramework if you have not already done so.)

private void Button1_Click(object sender, EventArgs e) {         Window window = new Window          {             Title = "My User Control Dialog",             Content = new MyUserControl()         };          window.ShowDialog(); } 
like image 54
user7116 Avatar answered Sep 19 '22 15:09

user7116