Exemple #1
0
		public MainWindow()
        {
            InitializeComponent();
		
            MakeMeasureMode.Children.Add(new MakeMeasureMode(_articles));
            WatchMode.Children.Add(new WatchMode(_articles));

			

			_addNewArticleCommand = new RelayActionCommand();
			AddNewArticleCommand.CanExecuteAction += IsCanExecute;
			AddNewArticleCommand.ExecuteAction += ShowNewArticleWindow;
		
		}
        public PersonViewModel()
        {
            objds   = new DataAccess();
            Persons = new ObservableCollection <PersonInfo>(objds.GetPersonData());

            var defaultView = CollectionViewSource.GetDefaultView(Persons);

            //The Command object is initialized where the 'CanExecuteAction' will be set True or False
            //based upon the State of the 'Name' property
            //The 'ExecuteAction' will accepts the data filtered from the collection
            //based upon the data entered in the TextBox
            SearchPersonCommand = new RelayActionCommand()
            {
                CanExecuteAction = n => !String.IsNullOrEmpty(Name),
                ExecuteAction    = n => defaultView.Filter = name => ((PersonInfo)name).FirstName.StartsWith(Name) ||
                                                             ((PersonInfo)name).LastName.StartsWith(Name) ||
                                                             ((PersonInfo)name).City == Name
            };
        }