Beispiel #1
0
        /// <summary>
        /// <see cref="DeleteButton"/>被点击,进入删除操作。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            var confirmResult = await new ContentDialog
            {
                Title               = ResourceLoader.GetString("DeleteFinanceDialog_Title"),
                Content             = String.Format(ResourceLoader.GetString("DeleteFinanceDialog_Content"), Finance.Event),
                PrimaryButtonText   = ResourceLoader.GetString("DeleteFinanceDialog_PrimaryButtonText"),
                SecondaryButtonText = ResourceLoader.GetString("DeleteFinanceDialog_SecondaryButtonText"),
                //DefaultButton = ContentDialogButton.Primary
            }.ShowAsync();

            if (confirmResult == ContentDialogResult.Primary)
            {
                var result = await api.DeleteFinance(Finance);

                if (result)
                {
                    await new ContentDialog
                    {
                        Title             = ResourceLoader.GetString("DeleteFinanceSuccessDialog_Title"),
                        PrimaryButtonText = ResourceLoader.GetString("DeleteFinanceSuccessDialog_PrimaryButtonText"),
                        //DefaultButton = ContentDialogButton.Primary
                    }.ShowAsync();

                    OnSubmitedSuccess?.Invoke(true);    // 调用委托,更新页面
                }
                else
                {
                    await new ContentDialog
                    {
                        Title             = ResourceLoader.GetString("DeleteFinanceFailDialog_Title"),
                        Content           = ResourceLoader.GetString("DeleteFinanceFailDialog_Content"),
                        PrimaryButtonText = ResourceLoader.GetString("DeleteFinanceFailDialog_PrimaryButtonText"),
                        //DefaultButton = ContentDialogButton.Primary
                    }.ShowAsync();
                }
            }
        }