示例#1
0
 public void OpenWindow(BaseViewModel context)
 {
     if (!_windows.ContainsKey(context))
     {
         PersonWindow window = new PersonWindow();
         window.DataContext = context;
         window.Show();
         _windows.Add(context, window);
     }
 }
示例#2
0
        private static void ExecuteBindableViewModel()
        {
            var window = new PersonWindow {
                DataContext = new BindablePerson()
                {
                    Name = "rimever"
                }
            };

            window.Show();
            window.Close();
        }
示例#3
0
        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));
        }
示例#4
0
        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;
            }
        }
示例#5
0
        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();
        }