是否可以合并Application.Resource,Window.Resource和Control.Resource字典? [英] Is it possible to merge Application.Resource, Window.Resource and Control.Resource dictionaries?

查看:86
本文介绍了是否可以合并Application.Resource,Window.Resource和Control.Resource字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在我的Excel VSTO AddIns中的WPF Toolkit项目中显示和使用下面的 DataGrid


      


使用它的常规(WPF)方式,依赖3个资源:Application.Resources(见下文),Window.Resources和Control.Resources。   


但是,只有后者才是正常的在Windows窗体项目下可用。合并3个资源是否有意义?还有其他选择吗?


TIA




解决方案

您好TIA,


是的,您可以创建全局资源并
让每个项目访问相应的资源文件。但我认为你的真正目的是在Winform应用程序中托管这个WPF控件,对吗?


如果是这样,你可以使用更多  合适的方式:使用WPF ElementHost:


ElementHost类


< a href ="https://docs.microsoft.com/en-us/dotnet/framework/winforms/advanced/walkthrough-assigning-wpf-content-on-windows-forms-at-design-time"target ="_ blank ">演练:在设计时在Windows窗体上分配WPF内容


演练:在Windows窗体中托管WPF复合控件


如何在Windows窗体应用程序中轻松托管WPF控件


问候,


Frankie


My objective is to display and use the DataGrid below, from the WPF Toolkit project in my Excel VSTO AddIns.

     

The regular (WPF) way of using it, relies on 3 resources: Application.Resources (see below), Window.Resources and Control.Resources.   

However, only the latter is normally available under a Windows Form project. Does it make sense to merge the 3 resources? Is there any other alternative?

TIA

解决方案

Hi TIA,

Yes you can create a global resource and let each project access the corresponding resource file. But I think your real purpose is hosting this WPF control in Winform application, right?

If so, you can do it with a more suitable way: using WPF ElementHost:

ElementHost Class

Walkthrough: Assigning WPF Content on Windows Forms at Design Time

Walkthrough: Hosting a WPF Composite Control in Windows Forms

How to Easily Host WPF Control inside Windows Form Application

Regards,

Frankie


这篇关于是否可以合并Application.Resource,Window.Resource和Control.Resource字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆