public void OpenWindow(BaseViewModel context) { if (!_windows.ContainsKey(context)) { PersonWindow window = new PersonWindow(); window.DataContext = context; window.Show(); _windows.Add(context, window); } }
private static void ExecuteBindableViewModel() { var window = new PersonWindow { DataContext = new BindablePerson() { Name = "rimever" } }; window.Show(); window.Close(); }
public void BindingAssert() { var window = new PersonWindow { DataContext = new PersonViewModel(new Person() { Name = "rimever" }) }; window.Show(); window.Close(); GC.Collect(); dotMemory.Check(memory => Assert.AreEqual(0, memory.GetObjects(where => where.Type.Is <PersonViewModel>()).ObjectsCount)); }
private static void ExecuteWeakPersonViewModel() { var p = new Person() { Name = "rim" }; foreach (var _ in Enumerable.Range(0, 2)) { var window = new PersonWindow { DataContext = new WeakPersonViewModel(p) }; window.Show(); window.Close(); window = null; } }
public void Navigate(ViewsEnum view) { switch (view) { case ViewsEnum.Table: _mainWindow.ContentControl.Content = _tableView; break; case ViewsEnum.AddView: if (!_personWindow.IsActive) { _personWindow = new PersonWindow(); _personWindow.Show(); _personWindow.ContentControl.Content = _personView; } break; case ViewsEnum.EditView: if (!_personWindow.IsActive && (UpdateManager.Instance._tableViewModel.EditedPerson != null)) { _personWindow = new PersonWindow(); _personView = new PersonView(UpdateManager.Instance._tableViewModel.EditedPerson, ViewsEnum.EditView); _personWindow.ContentControl.Content = _personView; _personWindow.Show(); } break; default: throw new ArgumentOutOfRangeException(nameof(view), view, null); } }
private void MenuPerson_OnClick(object sender, RoutedEventArgs e) { var win = new PersonWindow(); win.Show(); }