public ContragentForm() { InitializeComponent(); var vm = new ContragentFormViewModel(); this.DataContext = vm; if (vm.CloseAction == null) { vm.CloseAction = new Action(() => this.Close()); } }
public ContragentForm(IViewManager viewManager, IContragentService contragentService) { InitializeComponent(); ContragentFormViewModel vm = (ContragentFormViewModel)this.DataContext; // this creates an instance of the ViewModel if (vm.CloseAction == null) { vm.CloseAction = new Action(() => this.Close()); } vm.ViewManager = viewManager; vm.ContragentService = contragentService; }