I have three projects - "Bootstrapper", "ApplicationView" and "Presentation".
- A project "Bootstrapper" has app.xaml.cs file which runs a MainWindow
- A project "ApplicationView" has just necessary Windows - MainWindows.xaml, PersonWindow.xaml, SchoolWindows.xaml.
- A project "Presentation" has ViewModels classes and Interfaces
In my viewmodel I want to revoke a window. But where I should create a object of a window? I've read an article that I should create all instances of classes in App.xaml.cs file. But how to call this object at App.xaml.cs from viewModel? I cannot create objects in a ViewModel classes as I cannot add a reference of "BootStrapper" to "Presentation" because VS 2010 throws an error - "Adding this project as a reference would cause a circular dependency".
App.xaml.cs of "Bootstrapper" project:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ComposeObjects();
Application.Current.MainWindow.Title = "Loose Coupling - People Viewer";
Application.Current.MainWindow.Show();
}
private static void ComposeObjects()
{
//MainWindow
var repository = new ServiceRepository();
var viewModel = new PeopleViewerViewModel(repository);
Application.Current.MainWindow = new MainWindow(viewModel);
//SuperWindow
var salut = new ServiceSalutation();
var salutViewModel = new SuperWindowViewModel(salut);
var NewForm = new SuperWindow(salutViewModel);
}
MainWindowViewModel.cs of "Presentation" project:
void NewForm(object parameter)
{
//New Window
/*/var salut = new ServiceSalutation();
//var salutViewModel = new SuperWindowViewModel(salut);*/
//var NewForm = new SuperWindow();
How can I revoke a SuperWindow.xaml from a project "ApplicationView"?
}
How to call a SuperWindow.xaml of "Presentation" project from MainWindowViewModel.cs of Presentation project? I cannot add a reference of "BootStrapper" to "Presentation" because VS 2010 throws an error - "Adding this project as a reference would cause a circular dependency".