我想在Web浏览器中运行winform应用程序

我想在Web浏览器中运行winform应用程序

问题描述:

我正在尝试在wpf浏览器中托管winform应用程序

i创建了我的winform作为类库并将输出dll文件添加到我的wpf brwoser应用程序

它做得很好当我运行任何表格期望一个表格(IsMdiContianer)表格



i hade此错误System.Windows.Markup.XamlParseException未处理

消息:'匹配指定绑定约束的类型'WPFHost.Page1'上的构造函数的调用引发了异常。'行号'5'和行位置'7'。



i希望运行此容器表格





我的代码在Page1.xaml。



I'm trying to host winform application in wpf browser
i created my winform as Class Library and add the output dll file to my wpf brwoser application
it do well when i run any form expect one form (IsMdiContianer) form

i hade this Error "System.Windows.Markup.XamlParseException was unhandled
Message: 'The invocation of the constructor on type 'WPFHost.Page1' that matches the specified binding constraints threw an exception.' Line number '5' and line position '7'."

i want to run this container form


my code in Page1.xaml.

using System.Windows.Controls;
using System.Windows.Forms.Integration;
using Agility_Procurement_Application;

namespace WPFHost
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        private readonly FRM_Start mainForm = new FRM_Start();

        public Page1()
        {
            InitializeComponent();

            //Create a Windows Forms Host to host a form
            WindowsFormsHost windowsFormsHost = new WindowsFormsHost();


            stackPanel.Width = mainForm.Width;
            stackPanel.Height = mainForm.Height;
            windowsFormsHost.Width = mainForm.Width;
            windowsFormsHost.Height = mainForm.Height;

            mainForm.TopLevel = false;

            windowsFormsHost.Child = mainForm;

            stackPanel.Children.Add(windowsFormsHost);
        }
    }
}







我在第1页的代码.Xaml



< page x:class =WPFHost.Page1xmlns:x =#unknown>

xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation

xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml

xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006

xmlns:d =http://schemas.microsoft.com/表达/混合/ 2008

mc:Ignorable =dTitle =Page1d:DesignHeight =363d:DesignWidth =440>

< grid>

< stackpanel height =300name =stackPanelverticalalignment =Tophorizo​​ntalalignment =Leftwidth =300datacontext ={Binding}orientation =垂直>

< stackpanel.scrollowner>

< scrollviewer>









my code in Page1.Xaml

<page x:class="WPFHost.Page1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Title="Page1" d:DesignHeight="363" d:DesignWidth="440">
<grid>
<stackpanel height="300" name="stackPanel" verticalalignment="Top" horizontalalignment="Left" width="300" datacontext="{Binding}" orientation="Vertical">
<stackpanel.scrollowner>
<scrollviewer>



算了吧。不仅你做不到;它完全没有意义。



-SA
Forget it. Not only you cannot do it; it makes no sense at all.

—SA