【问题标题】:Call PrintDialog.ShowDialog() in a WPF UserControl which is hosted in WinForms Application在 WinForms 应用程序中托管的 WPF 用户控件中调用 PrintDialog.ShowDialog()
【发布时间】: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


    【解决方案1】:

    此处描述的解决方案/解决方法(德语):

    http://mobilesolutions.noser.com/2013/01/winforms-meets-wpf-meets-winforms-meets-wpf-2/

    【讨论】:

      猜你喜欢
      • 2012-03-27
      • 1970-01-01
      • 2016-10-29
      • 1970-01-01
      • 2018-03-10
      • 2013-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多