protected async override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var yourDependency = await YourClass.CreateAsync(); MainWindowViewModel vm = new MainWindowViewModel(yourDependency); MainWindow mainWindow = new WpfApplication4.MainWindow() { DataContext = vm }; mainWindow.Show(); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Window = ((WpfApplication4.MainWindow)(target)); return; case 2: this.LayoutRoot = ((System.Windows.Controls.Grid)(target)); return; case 3: this.ellipse = ((System.Windows.Shapes.Ellipse)(target)); return; } this._contentLoaded = true; }