Exemple #1
0
        public ViewModelMain()
        {
            People = new ObservableCollection<Person>
            {
                new Person { FirstName="Tom", LastName="Jones", Age=80 },
                new Person { FirstName="Dick", LastName="Tracey", Age=40 },
                new Person { FirstName="Harry", LastName="Hill", Age=60 },
            };
            TextProperty1 = "Type here";

            AddUserCommand = new RelayCommand(AddUser);
        }
Exemple #2
0
        public ViewModelWindow3(Person person)
        {
            People = new List<PocoPerson>
            {
                new PocoPerson{ FirstName=person.FirstName, LastName=person.LastName, Age=person.Age },
                new PocoPerson{ FirstName="Grace", LastName="Jones", Age=21 },
            };
            TextProperty1 = "Only this TextBox's changes are reflected in bindings";
            NextExampleCommand = new RelayCommand(NextExample);
            AddUserCommand = new RelayCommand(AddUser);

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
Exemple #3
0
        public ViewModelWindow4()
        {
            People = new List<PocoPerson>
            {
                new PocoPerson { FirstName="Tom", LastName="Jones", Age=80 },
                new PocoPerson { FirstName="Dick", LastName="Tracey", Age=40 },
                new PocoPerson { FirstName="Harry", LastName="Hill", Age=60 },
            };
            TextProperty1 = "This will now update";
            NextExampleCommand = new RelayCommand(NextExample);
            AddUserCommand = new RelayCommand(AddUser);

            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
Exemple #4
0
        public ViewModelWindow5()
        {
            personnel = new PersonnelBusinessObject();
            personnel.PeopleChanged += new EventHandler(personnel_PeopleChanged);

            CancelCommand = new RelayCommand(DoCancel);
            SaveCommand = new RelayCommand(DoSave);
            AddUserCommand = new RelayCommand(AddUser);
            DeleteUserCommand = new RelayCommand(DeleteUser);

            UpdateBindingGroup = new BindingGroup { Name = "Group1" };

            checkStatusTimer = new DispatcherTimer();
            checkStatusTimer.Interval = TimeSpan.FromMilliseconds(500);
            checkStatusTimer.Tick += new EventHandler(CheckStatus);
            checkStatusTimer.Start();

            CheckStatus(null, null);
        }
Exemple #5
0
 //This ViewModel is just to duplicate the last, but showing binding in code behind
 public ViewModelWindow1(string lastText)
 {
     _TestText = lastText; //Using internal variable is ok here because binding hasn't happened yet
     ChangeTextCommand = new RelayCommand(ChangeText);
     NextExampleCommand = new RelayCommand(NextExample);
 }
Exemple #6
0
 public ViewModelWindow2()
 {
     People = FakeDatabaseLayer.GetPeopleFromDatabase();
     NextExampleCommand = new RelayCommand(NextExample, NextExample_CanExecute);
 }