如何显示自定义 UserControl
作为 C#/WPF (.NET 3.5) 中的对话框?
最佳答案
将它放在 Window 中并调用Window.ShowDialog . (此外,添加对 PresentationCore、WindowsBase 和 PresentationFramework 的引用,如果您尚未这样做的话。)
private void Button1_Click(object sender, EventArgs e)
{
Window window = new Window
{
Title = "My User Control Dialog",
Content = new MyUserControl()
};
window.ShowDialog();
}
关于c# - 如何将自定义 UserControl 显示为对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1262115/