自定义控件的Corret方式 [英] Corret way for custom controls

查看:141
本文介绍了自定义控件的Corret方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨裂缝,



我写了一个WPF自定义控件库。所以在测试应用程序中使用它们时一切都很好。



我正在为Win32应用程序开发一个插件。在WPF元素主机中使用自定义控件时。 WPF UserControl抛出一个XAML.Parse异常FileNotFound。



所以我的伙伴告诉我在UC的代码隐藏文件中的代码中创建一个自定义控件。 br />
现在一切正常并且有效。



其他解决方案是将自定义控件库复制到Win32 App的应用程序文件夹中。



有人可以解释我发生了什么,或者我怎样才能避免这些问题。

这样我就不需要创建自定义在代码隐藏中控制或者我需要将我的自定义控件库复制到Win32应用程序文件夹。



非常感谢您的帮助



Greets Max



我尝试过:



将自定义控件库复制到Win32应用程序文件夹

在codebehind

Hi cracks,

i wrote a WPF custom control libary. So when using them in a test application everything is fine.

Im developing an addin for a Win32 application. When using my custom controls in an WPF element host. The WPF UserControl throws an XAML.Parse Exception "FileNotFound".

So my buddy told me to create a custom control in code in the codebehind file of the UC.
Now everything is fine and works.

Other solution was to copy the custom control libary to my application folder of the Win32 App.

Can anybody explain me what is happening or how can I avoid those problems.
So that I don't need to create a custom control in codebehind or that i need to copy my custom control libary to the Win32 application folder.

Your help would be very much appreciated

Greets Max

What I have tried:

Copy custom control libary to Win32 application folder
Create custom control in codebehind

推荐答案

中创建自定义控件,因为你问了这个问题。 .. - 现在你的部署怎么样?你做得对吗?



你的问题有点令人困惑,因为你谈到了一个CustomControl - 这是WPF中的一种特殊类型:你使用自己的ControlTemplate派生控件(主题)来自它 - 反对一起组合现有控件的UserControl - 更有可能在WPF中。所以我不明白你在代码背后是什么意思......

无论如何,如果你的控件在你的开发者pc上运行(所有的依赖存在),那么代码应该是合乎逻辑的不需要任何改变。您只是没有正确设置运行时环境。



一般情况下:如果您的应用程序需要具有控件/功能的库,则必须将其部署到目标计算机。最好的方法是在自动化,可重复和受控制的过程中完成此操作 - 使用SETUP;)



但是在创建设置之前,您必须了解参考和依赖项适用于您的目标系统以及您的编程平台和语言/框架。如果你在这个主题上花几分钟时间阅读MSDN,它似乎不会造成任何伤害?例如这里管理依赖关系 [ ^ ]
some time since you asked this question... - what about your deployment now? Did you get it right?

Your question is a little confusing because you talk about a CustomControl - this is a special type in WPF: you derive controls with your own ControlTemplate (theme) from it - opposed to a UserControl where you compose existing controls together - far more likely in WPF). So I don't understand what you mean with "in code behind"...
Anyway, if your control worked on your developer pc(where all dependencies existed) it should be logical that the code doesn't need any change. You just didn't setup your runtime environment correctly.

In general: If you have a library with controls/functions your application needs, you have to deploy it to the target computer. Best way is to do this in an automated, repeatable, and controlled process - with a SETUP ;)

But before you can create a setup you have to understand how references and dependencies work on your target systems and for your programming platform and language/framework. It seems it could not do any harm if you spend some minutes reading MSDN on this topic? e.g. here Managing Dependencies[^]


这篇关于自定义控件的Corret方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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