Example #1
0
 public void BindViewModel <T>(T viewModel) where T : IViewModel
 {
     view.DataContext      = viewModel;
     viewModel.CloseWindow = () =>
     {
         OnClose?.Invoke();
         view.Close();
     };
 }
Example #2
0
        private void addModelApply(object sender, EventArgs e)
        {
            if (!(locationViewModel.NewLocation.City == null || locationViewModel.NewLocation.Name == null || locationViewModel.NewLocation.Street == null || locationViewModel.NewLocation.StreetNumber == null || locationViewModel.NewLocation.ZipCode == 0))
            {
                _repository.InsertLocation(locationViewModel.NewLocation);
                foreach (var tree in locationViewModel.NewTreeTypeToMeasures)
                {
                    tree.LocationId = locationViewModel.NewLocation.Id;
                    _repository.InsertTreeTypeToMeasure(tree);
                }


                RaisePropertyChanged("Locations");
                RaisePropertyChanged("Trees");
                CurrentSearchString = "";
            }
            else
            {
                MessageBox.Show("Alle felter skal udfyldes", "Fejl", MessageBoxButton.OK);
            }


            locationWindow.Close();
        }