zoukankan      html  css  js  c++  java
  • WPF 嵌入winform 控件

    引入 WindowsFormsIntegration.dll   和   System.Windows.Forms.dll

      

    <Window x:Class="wgscd.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:WinFormHost="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
    xmlns:WinFormControls="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" Title="Window1" Height="362" Width="655">
        <Grid Name="grid">
            <WindowsFormsHost  Margin="0,65,0,0" Name="windowsFormsHost1" >
                <WinFormControls:WebBrowser  x:Name="web"/>
            </WindowsFormsHost>
            <Button Height="39" VerticalAlignment="Top"  HorizontalAlignment="Left" Width="159" Margin="107,20,0,0" Click="Button_Click">gggg</Button>
        </Grid>
    </Window>
    

      

    也可以代码动态添加:

    System.Windows.Forms.Integration.WindowsFormsHost host =
                    new System.Windows.Forms.Integration.WindowsFormsHost();
              
             System.Windows.Forms.WebBrowser web = new System.Windows.Forms.WebBrowser();
             
             web.Url = new Uri("http://www.baidu.com");
                
             host.Child = web;
              
             this.grid.Children.Add(host);
    

      

  • 相关阅读:
    java线程
    windows Server 安装
    nginx正则反向代理
    crontab定时任务启动脚本失败
    数据结构
    异常概念
    shell日期遍历复制文件
    多态和抽象
    图1 列出连通集
    PTA 代码注意事项
  • 原文地址:https://www.cnblogs.com/wgscd/p/9994557.html
Copyright © 2011-2022 走看看