我正在为数据库迁移做一个应用程序。我用WPF GUI制作了一个多线程框架。我把成才像这样在我的命名空间/文件夹:WPF“部分形式”
class Something : Migrator {
public override Run(){
//I would need this
string valueOfMyCustomFieldOnForm = xyz.Text; //example
int count = 500;
for(int i = 0; i < 500; i++){
//do something here
OnProgressChanged(...); //call event, GUI is updated
}
OnCompleted(...); //migration completed
}
}
然后使用反射,我把所有的类在命名空间在下拉列表中。当我在列表中选择一个并单击“开始”时,将启动Run方法中带有代码的线程。
DB Host: TEXTBOX
DB Username: TEXTBOX
DB Password: TEXTBOX
--
Migrator custom field 1: TEXTBOX
Migrator custom field 2: TEXTBOX
...
--
List with migrated items - irrelevant
GUI上很少有commong字段(如数据库主机,用户名等)。但对于其中一些迁移者,我需要GUI上的自定义字段(例如3个额外的文本框字段)。 什么是在WPF中做到这一点的最佳方式?我需要GUI的一部分是动态的。