【发布时间】:2012-10-30 13:29:10
【问题描述】:
我有一个使用 System.Windows.Controls.PrintDialog 的 WPF UserControl:
XAML:
<UserControl x:Class="WpfControlLibrary1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Button Click="Button_Click"/>
</UserControl>
代码隐藏:
namespace WpfControlLibrary1
{
using System.Windows;
using System.Windows.Controls;
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var printer = new PrintDialog();
printer.ShowDialog();
}
}
}
如果我现在在 WPF 应用程序中使用此 UserControl,则 PrintDialog-Windows 将显示为模式对话框。 (如msdn中所述)
但如果我在 Wondows-Forms 应用程序中使用 UserControl,则对话框会显示为非模态对话框。
任何人知道当我在 Windows-Forms 应用程序中托管用户控件时如何将 PrintDialog 调用为模式对话框?
感谢您的期待 rhe1980
【问题讨论】:
标签: c# wpf winforms printdialog windowsformsintegration