我需要在MainWindow中有一些参数,如下所示:
public MainWindow(DbContext _ctx, string dbSetName)
{
Type setType = Type.GetType(dbSetName);
Type gType = typeof(GenericViewModel<>).MakeGenericType(setType);
var oVM = Activator.CreateInstance(gType);
this.DataContext = oVM;
InitializeComponent();
}
现在我想从另一个项目中显示MainWindow:
var w = new MainWindow (PersonCbContext, "People"
我得到一个例外说:
"The calling thread must be STA, because many UI components require this."