是否可以在Windows窗体中托管MVVMLight WPF应用程序的窗口?什么是正确的自举程序?
更新
通过查看App.xaml的InitializeComponent中的内容,我能够像这样引导MVVMLight:
在Program.cs
中 [STAThread]
static void Main()
{
var wpfApp = new WpfApp();
Uri resourceLocater = new System.Uri("/AssemblyName;component/app.xaml", System.UriKind.Relative);
System.Windows.Application.LoadComponent(wpfApp, resourceLocater);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
然后,在我的on-click事件处理程序中,为了显示我可以使用的MainControl WPF UserControl:
var window = new MainControl();
var form = new Form(){MdiParent = this};
form.Controls.Add( new ElementHost(){Dock = DockStyle.Fill, Child = window } );
form.Show();
如果没有人有更好的想法,我会在几天内接受这个答案。
答案 0 :(得分:0)
[STAThread]
static void Main()
{
var wpfApp = new WpfApp();
Uri resourceLocater = new System.Uri("/AssemblyName;component/app.xaml", System.UriKind.Relative);
System.Windows.Application.LoadComponent(wpfApp, resourceLocater);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}