首页 > 系统相关 >WPF System.WIndows.Forms add wpf control

WPF System.WIndows.Forms add wpf control

时间:2025-01-01 21:08:32浏览次数:9  
标签:control WIndows System Forms Windows using WPF expander

1.New System.Windows.Forms project;

2.Add reference C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll

3.Drag ElementHost from Toolbox to WindowsForms

 

 

4.Add reference PresentationCore.dll;

Add reference PresentationFramework.dll;

 

5.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using System.Windows.Media;

namespace WindowsFormsApp1
{    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Expander expander = new Expander();
            expander.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255,0,0));   
            expander.Header = "WPF Expander";

            WindowsFormsHost host = new WindowsFormsHost();
            host.Child = new MonthCalendar();
            expander.Content = host;
            label1.Text = "WPF expander control in System.Windows.Forms";
            elementHost1.Child= expander;
        }
    }
}

 

 

 

 

 

 

. Both Color types have a FromArgb static method, so you can create one Color from the other by passing this method the A, R, G, and B values from the source Color.
. To get a Windows Forms font size from a WPF font size, multiply the value by 0.75. To get a WPF font size from a Windows Forms font size, divide the value by 0.75.

标签:control,WIndows,System,Forms,Windows,using,WPF,expander
From: https://www.cnblogs.com/Fred1987/p/18646301

相关文章

  • WPF add System.Windows.Forms.PropertyGrid via WindowsFormsHost
    1.AddreferenceSystem.Windows.Forms.dll;2.Addreference C:\ProgramFiles\ReferenceAssemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll3.//xaml<Windowx:Class="WpfApp131.MainWindow"xmlns="http://schemas.mi......
  • WPF call Windows.Forms.PropertyGrid in xaml
    1.AddreferenceSystem.Windows.Forms;2.Addreference C:\ProgramFiles\ReferenceAssemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll3.<Windowx:Class="WpfApp132.MainWindow"xmlns="http://schemas.microsoft.com......
  • [Windows] 启动 Windows Update 服务失败,报:"Windows 无法启动 Windows Update 服务(
    1问题描述现象1:Windows10家庭版-服务(services.msc)-启动WindowsUpdate服务失败,报:"Windows无法启动WindowsUpdate服务(位于本地计算机上)错误126:找不到指定的模块"注:C:\Windows\System32\wuaueng.dll文件存在注:注册表regedit:计算机\HKEY_LOCAL......
  • 记录学习使用stylecontrols5.8控件的几个坑(二)
    坑2:使用scDBImage显示数据库图片,当DBImageZhaoPian.Picture.LoadFromFile(opd.FileName);//或者TBlobField(dm.FDQPerson.FieldByName('照片')).LoadFromStream(ms);//或TBlobField(dm.FDQPerson.FieldByName('照片')).LoadFromfile(filename);之后,scdbimage能显示图片,当执......
  • Create a Ubuntu Virtual Machine using VirtualBox 7.1 for Windows
                  ......
  • JupyterLab notebook环境在Ubuntu24.04下的安装和Windows 10下vscode远程使用jupyter
    JupyterLabnotebook环境在Ubuntu24.04下的安装,并在Windows10下通过vscode远程使用jupyter安装jupyterLab首先,创建python环境(可选)python-mvenvpy312激活环境sourcepy312/bin/activate安装jupyterlabpipinstalljupyterlab启动服务jupyter-lab--ip0.0.0.0......
  • install-double-system
    Windows和Ubuntu双系统的安装和卸载-哔哩哔哩一、进入windows系统对磁盘进行分区注意不要给空白分区分配卷名二、重启电脑,使用ventoryU盘启动器安装ubuntu系统注意要关闭,安全启动选项,lenovo是f2否则不能识别ventoryGPT分区安装方案引导区:500MB,EFI系统分区内存交换......
  • Windows应用开发-常用工具集推荐
     .NET/WPF开发VisualStudio最新版本是VS2022,官网下载:VisualStudio2022IDE-适用于软件开发人员的编程工具VsColorOutput控制台可视化很强、编译会区分颜色输出,在VS扩展中在线安装最新VsColorOutput64Reshaper极大提升编码效率。官网下载 https://www.jetbrains.com......
  • Detego Analyse 4.10 for Windows - 证据收集、分析和报告
    DetegoAnalyse4.10forWindows-证据收集、分析和报告Unlockpowerfulanalyticsandcourt-readyreporting请访问原文链接:https://sysin.org/blog/detego-analyse/查看最新版。原创作品,转载请保留出处。作者主页:sysin.orgDetegoAnalyseUnlockpowerfulanalyticsan......
  • QT程序监控不到拖拽事件如dragEnterEvent - Windows权限问题的解决方案
    问题:当客户端已高完整性启动(例如启动客户端的进程是BypassUAC启动的高完整性的进程,导致客户端继承了其高完整性),由于explorer.exe资源管理器是以中等Medium权限启动,客户端的权限较高,导致设置了qt编写的客户端设置了的setAcceptDrops(true)后依然无法触发dropEvent,导致无法接受其它......