• how to reference the parent form from the WPF control(Control in ElementHost)


    Winform 中放置 ElementHost 控件加载 wpf 的 UserControl

    在 WPF UserControl 中获取 winform 的方法

        public partial class CrlDefinition : UserControl
        {
            public CrlDefinition()
            {
                InitializeComponent();
    this.Loaded += CrlDefinition_Loaded;
            }
    
            void CrlDefinition_Loaded(object sender, RoutedEventArgs e)
            {
                var source = (HwndSource)PresentationSource.FromDependencyObject(this);
                var host = (System.Windows.Forms.Integration.ElementHost)System.Windows.Forms.Control.FromChildHandle(source.Handle);
                var form = (System.Windows.Forms.Form)host.TopLevelControl;
                // Show form title
                MessageBox.Show(form.Text);
            }
    ----------------------------------- http://www.cnblogs.com/rock_chen/
  • 相关阅读:
    简单批处理语法结构
    简单批处理常用命令
    简单批处理符号简介
    简单批处理内部命令
    jQuery操作DOM
    jQuery中的事件与动画
    jQuery选择器
    初始面向对象
    初识jQuery
    操作DOM
  • 原文地址:https://www.cnblogs.com/rock_chen/p/2978313.html
Copyright © 2020-2023  润新知