Example #1
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(Defaults.APPLICATION_ID) || string.IsNullOrEmpty(Defaults.SECRET_KEY) ||
                string.IsNullOrEmpty(Defaults.VERSION))
            {
                NavigationService.Navigate(new Uri("/ErrorPage.xaml", UriKind.Relative));
                return;
            }

            Backendless.InitApp(Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);
            DataStore = Backendless.Persistence.Of <ToDoEntity>();

            EntitiesDataGrid.DataContext = _toDoList;
            _toDoList.CollectionChanged +=
                (senderObj, args) => Footer.Visibility = _toDoList.Count == 0 ? Visibility.Collapsed : Visibility.Visible;

            AsyncStartedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Visible;
                ContentPanel.Opacity   = 0.1;
            };
            AsyncFinishedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Collapsed;
                ContentPanel.Opacity   = 1;
            };

            AsyncStartedEvent.Invoke();
            DataStore.Find(new AsyncCallback <BackendlessCollection <ToDoEntity> >(response => Dispatcher.BeginInvoke(() =>
            {
                _toDoList.AddAll(response.GetCurrentPage());
                AsyncFinishedEvent.Invoke();
            }), fault => Dispatcher.BeginInvoke(() => AsyncFinishedEvent.Invoke())));
        }