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);
    

      

  • 相关阅读:
    时间日期date/cal
    chown命令
    su命令
    which命令和bin目录
    python基础之文件操作
    python之模块之shutil模块
    python基础之面向对象01
    python基础之面向对象02
    python基础之map/reduce/filter/sorted
    python基础之模块之序列化
  • 原文地址:https://www.cnblogs.com/wgscd/p/9994557.html
Copyright © 2011-2022 走看看