本文介绍了如何以其ClassName作为参数打开Silverlight ChildWindow?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要基于定义子窗口名称或类的参数创建一种方法来打开子窗口.
此参数存储在SQL的表中,我不知道该打开哪个女巫窗口,因为它取决于用户选择.

我以为我会使用通用类ChildWindow并创建类似以下内容的内容:

Hi
I need to create way to open a child window based on a parameter that would define the child window name or class.
This parameter is stored in a table in SQL and I don''t know in advance witch child window is supposed to be open for it would depend on a user choice.

I thought I''d use generic class ChildWindow and create something like:

ChildWindow cw = new ChildWindow();
//How to direct cw to myCwClass?
cw.Show();



我有很多子窗口,使用switch()命令或嵌套if只是不切实际.

Google并没有很大的帮助!

有谁知道实现此目标的方法或任何可以在其中看到示例的Web链接?

感谢



I have a lot of child windows and it''s just not practical to use the switch() command or nested if''s.

Google hasn''t been of great help!

Does anyone know a way to achieve this or knows any web link where I can see an example?

Thanks

推荐答案


Type cwType = Type.GetType("myNamespace.myCwClass");
object cw = Activator.CreateInstance(cwType);
((ChildWindow)cw).Show();



我的5!



My 5!


这篇关于如何以其ClassName作为参数打开Silverlight ChildWindow?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 14:06