Example #1
0
        public async void Add()
        {
            var task = new TaskTodoVM();                               // create new view model of a task

            string userInput = await InputTextDialogAsync("New Task"); // call a method that represents dialog with a user

            // obtain result of an input
            if (userInput.Length == 0) /* do nothing */ } {
Example #2
0
        // Constructor
        public TodoCollectionVM()
        {
            // Create new Model that you want to wrap in View Model
            // Model can have a data already in it or may call http services to obtain it
            Debug.WriteLine("Constructing VM");
            todoCollection = new TodoCollection();

            myGeoService = new GeoLocationService(); // create instance of Geo Service
            myGeoService.initialiseGeoLocation();    // initialise service, ask user for access
            Debug.WriteLine(myGeoService.Geo_status);

            _SelectedIndex = -1; // Set selected index in ListView to nothing.
                                 // This property has x:Bind to it's getter in ListView on Page

            // Loop over collection in Model and add each Todo task from it to a ViewModel (ObservableCollection)
            foreach (var task in todoCollection.TodoList)
            {
                var nt = new TaskTodoVM(task); // Note that ObservableCollection _TodoList
                                               // takes objects of type TaskTodoVM that is wrapping
                                               // POCO Model for Task on the List.
                // nt.PropertyChanged += Task_OnNotifyPropertyChanged; //
                _TodoList.Add(nt);
            }
        }