继承UserControl不起作用 [英] Inherit UserControl does not work

查看:110
本文介绍了继承UserControl不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从UserControl继承,但它不能正常工作: - (

I want to inherit from a UserControl, but it is not working :-(

我有一个程序集"MyAssembly"。在其中我有一个类"MyUserControl",它派生自UserControl(WPF)。

I have a Assembly "MyAssembly". In it I have a Class "MyUserControl" which derives from UserControl (WPF).

然后我有一个WPF项目,我添加了一个UserControl并更改了XAML和代码隐藏文件,因此它派生自MyUserControl。

Then I have a WPF project where I added a UserControl and changed the XAML and code behind file, so that it derives from MyUserControl.

问题是,设计器无法显示UserControl(MyUserControl)。我不想将MyUserControl添加到窗口!我只想直接使用MyUserControl,并希望使用Designer或XAML文件添加控件。

The problem is, that the designer is not able to show the UserControl (MyUserControl). I do not want to add MyUserControl to a Window! I just want to have directly the MyUserControl and want to add Controls with the Designer or XAML file.

原因是,我希望UserControl具有相同的基本功能和UserControl应该在我想要的任何项目中使用。基本UserControl(MyUserControl)没有XAML代码,只有类中的一些功能。

The reason is, that I want to have a UserControl with same basic functionality and this UserControl should be used in any project I want. The base UserControl (MyUserControl) has no XAML code, only some functionality in the class of it.

 

 

推荐答案

是Xaml文件的根目录o f键入MyUserControl或UserControl?它应该是MyUserControl。如果是,那么你可以发布MyUserControl的代码以及你用来尝试从中派生的Xaml吗?

Is the root of your Xaml file of type MyUserControl or UserControl? It should be MyUserControl. If it is then can you post of the code from both MyUserControl and also the Xaml that you are using to attempt to derive from it?


这篇关于继承UserControl不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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