示例#1
0
        private void SaveCategory()
        {
            if (string.IsNullOrEmpty(categoryNameTextBox.Text))
            {
                MessageBox.Show(_localizedStrings.Prompts.MissingCategoryName);
                categoryNameTextBox.Focus();
                return;
            }

            this.Focus(); //hide the keyboard

            //force updates to the data context
            categoryNameTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            categorySlugTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
            categoryDescriptionTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();

            Category newCategory = DataContext as Category;

            newCategoryRPC            = new NewCategoryRPC(App.MasterViewModel.CurrentBlog, newCategory);
            newCategoryRPC.Completed += OnNewCategoryRPCCompleted;
            newCategoryRPC.ExecuteAsync();

            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.CreatingNewCategory);
        }
示例#2
0
        private void OnNewCategoryRPCCompleted(object sender, XMLRPCCompletedEventArgs <Category> args)
        {
            NewCategoryRPC rpc = sender as NewCategoryRPC;

            rpc.Completed -= OnNewCategoryRPCCompleted;

            if (args.Cancelled)
            {
                ApplicationBar.IsVisible = true;
                App.WaitIndicationService.HideIndicator();
            }
            else if (null == args.Error)
            {
                DataService.Current.FetchComplete += OnFetchCurrentBlogCategoriesComplete;
                DataService.Current.FetchCurrentBlogCategories();
            }
            else
            {
                ApplicationBar.IsVisible = true;
                App.WaitIndicationService.HideIndicator();
                this.HandleException(args.Error);
            }
        }