zoukankan      html  css  js  c++  java
  • windows窗体程序中使用WPF控件 Host WPF Controls in Windows Forms Application

    参考http://keyvan.io/host-wpf-controls-in-windows-forms

    在windows form appliation中添加wpf空间,需要使用一个ElementHost的容器,接着将创建出来的WPF对象赋值到ElementHost的child属性中,类似子控件添加到Panel或者Form的controls容器中,可以ElementHost只能对应一个wpf控件,接着将ElementHost添加到父级Controls中。

    实现如下:

    1. 创建Windows Form Application项目,命名为HostWPFWinForm

    Picture 2013-06-15 12_30_32

    2. 接着添加新建项为“用户控件(WPF)”,命名为MyWPFControl

    Picture 2013-06-15 12_33_43

    3. 给刚生成的WPF控件添加lable, textbox 与button,对应的XAML如下:

    Code

    对应的CS代码为:

    Code

    4. 添加外部DLL库:windowsformsintegration, system.xaml

    5. 修改Form1代码如下

    Code

    6. 编译并且运行程序,效果图如下:

    Picture 2013-06-15 15_25_29


     


     

  • 相关阅读:
    react-redux-reducer
    react-redux-action
    node-express-2-jade
    node-express-1
    vuex-Module
    vuex-Action(异步)
    vuex-Mutation(同步)
    vuex-getter
    vuex-state
    ##DAY7 UINavigationController
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/3137624.html
Copyright © 2011-2022 走看看