C#UWP-App:ContentDialog跳过指令块

时间:2017-05-04 11:14:31

标签: c# dialog uwp

我在C#中使用VS2017。我使用ComboBox创建了一个ContentDialog,用户可以在其中选择会议需要多长时间。用户还可以选择创建会议,直到下一个会议开始。

我的问题:当点击PrimaryButton或SecondaryButton时,会跳过指令。我添加了断点但应用程序正在完成而不会中断。

private async void Funkt1_Click(object sender, RoutedEventArgs e)
    {
        var dialog = new ContentDialog()
        {
            Title = "Book Prometheus "
        };
        var panel = new StackPanel();
        panel.Children.Add(new TextBlock
        {
            Text = "Choose how long you require the Prometheus." +
            "With a click on the right button, Prometheus will be booked as long as possible.",
            TextWrapping = TextWrapping.Wrap,
        });
        var cb = new ComboBox();
        cb.Items.Add("30 Minutes");
        cb.Items.Add("60 Minutes");
        cb.Items.Add("90 Minutes");
        cb.SetBinding(ComboBox.SelectedItemProperty, new Binding
        {
            Source = dialog,
            Path = new PropertyPath("IsPrimaryButtonEnabled"),
            Mode = BindingMode.TwoWay 
        });

        panel.Children.Add(cb);
        dialog.Content = panel;
        dialog.PrimaryButtonText = "Book";
        dialog.SecondaryButtonText = "Book to next meeting";
        await dialog.ShowAsync();


            if (cb.SelectedItem != null)
            {
                dialog.IsPrimaryButtonEnabled = true;
            } 
         dialog.PrimaryButtonClick += async delegate
        {
            if (cb.SelectedItem == cb.Items[0])
            {
                terminende = DateTime.Now.AddMinutes(30).ToString("yyyy-MM-dd'T'HH:mm:ss");
            }
           if  (cb.SelectedItem == cb.Items[1])
            {
                terminende = DateTime.Now.AddMinutes(60).ToString("yyyy-MM-dd'T'HH:mm:ss");
            }
           if (cb.SelectedItem == cb.Items[2])
            {
                terminende = DateTime.Now.AddMinutes(90).ToString("yyyy-MM-dd'T'HH:mm:ss");
            }

            terminstart = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss");

           await _mailHelper.machTerminDahin();

        };

        dialog.SecondaryButtonClick +=  delegate
        {

            terminende = MailHelper.alleventstoday.value[0].Start.DateTime;   //.ToString("yyyy-MM-dd'T'HH:mm:ss");
            terminstart = DateTime.Now.ToString("yyyy-MM-dd'T'HH:mm:ss");
             _mailHelper.machTerminDahin();

        };
    }

0 个答案:

没有答案