将Combobox绑定到使用MEF继承接口的类(Managed extensibility framework .. [英] Bind Combobox with classes who inherit interface using MEF(Managed extensibility framework ..
本文介绍了将Combobox绑定到使用MEF继承接口的类(Managed extensibility framework ..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请遵守代码流程。
我有一个接口Ishape,它在一些独立的dll或类库中。
Please under stand the flow of code .
I have an interface Ishape which in some separate dll or class library.
[InheritedExport]
public interface Ishape
{
int Paint(int width, int height);
}
在我的窗口应用程序中,我有两节课。
In my window application I have two classes.
public class Circle : MEF_Test.Ishape
{
public int Paint(int width, int height)
{
return 0;
}
}
[Export(typeof(Ishape))]
public class Rect : MEF_Test.Ishape
{
public int Paint(int width, int height)
{
return 0;
}
}
我想要绑定类继承接口IShape的组合框中的名称。
我是窗口应用程序和MEF(托管扩展框架)的新手
请有人帮忙。我需要尽快。
提前致谢
注意
I want to bind class names in combobox who inherit interface IShape .
I am new to both window application and MEF ( managed extensibilty Framework )
Please somebody help . I need it as soon as possible .
Thanks in advance
Regard
推荐答案
>
只需使用元数据,例如:
[ExportMetadata(Name,ControlsLibrary1.BlueControl) ]
然后当你加载所有形状时,你可以将它们添加到组合框。
您可以在我的文章中阅读更多相关信息:
使用MEF完全懒惰DLL加载的最简单方法 [ ^ ]
我希望它可以帮到你:)
Hi,
Just use the meta data for example:
[ExportMetadata("Name", "ControlsLibrary1.BlueControl")]
Then when you load all of the Shapes you can add them to the Combo-Box.
You can read more about it in my article:
The Simplest Way to use MEF Fully Lazy DLL Loading[^]
I hope it would help you :)
这篇关于将Combobox绑定到使用MEF继承接口的类(Managed extensibility framework ..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文