I'm trying to learn WPF and have a case where i have to pass a command line argument to a viewmodel. i was able to get the parameter from app.xaml and pass to MainWindow, but how do i get this parameter from mainwindow to the viewmodel. also if i add a constructor to the view model, then i cant declare it in in the datacontent in the xaml view - if i do it in the codebehind, i dont get the intellisense, which i another problem.
If you could point me to a simple example or even the pattern if need to do this type of thing that would be great.
View model
public class RepoViewModel
{
private VcsRepo repo;
public RepoViewModel()
{
// this is where i need that parameter from mainwindow
this.repo = new VcsRepo(new Repository([my parameter]));
}
public VcsRepo Repo
{
get { return repo; }
set { repo = value; }
}
}
The view
<UserControl.DataContext>
<local:RepoViewModel/>
</UserControl.DataContext>
<Grid>
<DataGrid ItemsSource="{Binding Repo.Files}"/>
</Grid>
</UserControl>