1. <tfoot id='Y0PP4'></tfoot>

      <legend id='Y0PP4'><style id='Y0PP4'><dir id='Y0PP4'><q id='Y0PP4'></q></dir></style></legend>

      • <bdo id='Y0PP4'></bdo><ul id='Y0PP4'></ul>
    2. <i id='Y0PP4'><tr id='Y0PP4'><dt id='Y0PP4'><q id='Y0PP4'><span id='Y0PP4'><b id='Y0PP4'><form id='Y0PP4'><ins id='Y0PP4'></ins><ul id='Y0PP4'></ul><sub id='Y0PP4'></sub></form><legend id='Y0PP4'></legend><bdo id='Y0PP4'><pre id='Y0PP4'><center id='Y0PP4'></center></pre></bdo></b><th id='Y0PP4'></th></span></q></dt></tr></i><div id='Y0PP4'><tfoot id='Y0PP4'></tfoot><dl id='Y0PP4'><fieldset id='Y0PP4'></fieldset></dl></div>

        <small id='Y0PP4'></small><noframes id='Y0PP4'>

        UWP 中带有 3 个以上按钮的自定义内容对话框

        时间:2023-09-14
        • <tfoot id='xbD4b'></tfoot>

          <small id='xbD4b'></small><noframes id='xbD4b'>

            <bdo id='xbD4b'></bdo><ul id='xbD4b'></ul>

                <tbody id='xbD4b'></tbody>
              <legend id='xbD4b'><style id='xbD4b'><dir id='xbD4b'><q id='xbD4b'></q></dir></style></legend>

                1. <i id='xbD4b'><tr id='xbD4b'><dt id='xbD4b'><q id='xbD4b'><span id='xbD4b'><b id='xbD4b'><form id='xbD4b'><ins id='xbD4b'></ins><ul id='xbD4b'></ul><sub id='xbD4b'></sub></form><legend id='xbD4b'></legend><bdo id='xbD4b'><pre id='xbD4b'><center id='xbD4b'></center></pre></bdo></b><th id='xbD4b'></th></span></q></dt></tr></i><div id='xbD4b'><tfoot id='xbD4b'></tfoot><dl id='xbD4b'><fieldset id='xbD4b'></fieldset></dl></div>

                  本文介绍了UWP 中带有 3 个以上按钮的自定义内容对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想显示一个内容对话框,它比传统的主要和次要结果更多.由于我无法覆盖 ContentDialogResult 枚举并向该属性添加选项,看来我唯一的选择可能是创建我自己的与 ContentDialog 类似的自定义控件.

                  附加上下文:通常,在计算机/应用程序操作期间可能会看到一个对话框,当操作是多余的,即复制文件到文件夹时,计算机通常会提供一个对话框,而不是两个选项,而是4.->对所有人都同意"、对所有人都没有"、是"、否".我似乎找不到任何千篇一律的方法来利用这种看似常见的做法.
                  我想像使用普通的内容对话框一样使用它:

                  var dialog = new MyCustomContentDialog();var 结果 = dialog.ShowAsync();

                  然后像普通的 ContentDialog 一样返回一个枚举,而是让它返回 4 个选项中的 1 个,而不仅仅是 2 个.

                  任何帮助或建议都会很棒.谢谢.

                  解决方案

                  我想显示一个内容对话框,它比传统的主要和次要结果更多.

                  I'd like to display a content dialog box that has more than the traditional Primary and Secondary results. Since I can't override the ContentDialogResult enum and add options to that property, it seems my only choice may be to create my own custom control that works similarly to a ContentDialog.

                  For additional context: Often, one might see a Dialog box show up during a computer/app operation, when the action is redundant, i.e. copying files to a folder, the computer generally offers a dialog box with not 2 options, but 4. -> "Yes to All", "No to All", "Yes", "No". I can't seem to find any cookie cutter ways to take advantage of this seemingly common practice.
                  I'd like to use it just the same as a normal Content Dialog like so:

                  var dialog = new MyCustomContentDialog();
                  var result = dialog.ShowAsync();
                  

                  and then return an enum just as the normal ContentDialog but instead have it return 1 of 4 options, not just 2.

                  Any help or recommendations would be great. Thanks.

                  解决方案

                  I'd like to display a content dialog box that has more than the traditional Primary and Secondary results.

                  The ContentDialog has 2 built-in buttons(the primary/secondary button) that let a user respond to the dialog. If you want more buttons to let the user to respond to the dialog, you should be able to achieve this by including these buttons in the content of the dialog.

                  Following is a simple sample shows how to create and use a custom dialog with 3 button:

                  MyCustomContentDialog.xaml

                  <ContentDialog
                  x:Class="ContentDialogDemo01.MyCustomContentDialog"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:local="using:ContentDialogDemo01"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  mc:Ignorable="d"
                  x:Name="dialog"
                  Title="Delete">
                  
                  <!-- Content body -->
                  <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0,20">
                      <Grid.RowDefinitions>
                          <RowDefinition />
                          <RowDefinition Height="200" />
                      </Grid.RowDefinitions>
                      <Grid.ColumnDefinitions>
                          <ColumnDefinition />
                          <ColumnDefinition />
                          <ColumnDefinition />
                      </Grid.ColumnDefinitions>
                      <TextBlock Grid.ColumnSpan="3" Text="Delete file A?" Margin="5" />
                      <Button Grid.Row="1" Content="Yes" x:Name="btn1" Click="btn1_Click" Margin="5,0" Width="100" />
                      <Button Grid.Row="1" Grid.Column="1" Content="No" x:Name="btn2" Click="btn2_Click" Margin="5,0" Width="100" />
                      <Button Grid.Row="1" Grid.Column="2" Content="Cancle" x:Name="btn3" Click="btn3_Click" Margin="5,0" Width="100" />
                  </Grid>
                  </ContentDialog>
                  

                  MyCustomContentDialog.xaml.cs

                  namespace ContentDialogDemo01
                  {
                  // Define your own ContentDialogResult enum
                  public enum MyResult
                  {
                      Yes,
                      No,
                      Cancle,
                      Nothing
                  }
                  
                  public sealed partial class MyCustomContentDialog : ContentDialog
                  {
                      public MyResult Result { get; set; }
                  
                      public MyCustomContentDialog()
                      {
                          this.InitializeComponent();
                          this.Result = MyResult.Nothing;
                      }
                  
                      // Handle the button clicks from dialog
                      private void btn1_Click(object sender, RoutedEventArgs e)
                      {
                          this.Result = MyResult.Yes;
                          // Close the dialog
                          dialog.Hide();
                      }
                  
                      private void btn2_Click(object sender, RoutedEventArgs e)
                      {
                          this.Result = MyResult.No;
                          // Close the dialog
                          dialog.Hide();
                      }
                  
                      private void btn3_Click(object sender, RoutedEventArgs e)
                      {
                          this.Result = MyResult.Cancle;
                          // Close the dialog
                          dialog.Hide();
                      }
                  }
                  }
                  

                  Here is the code to show the custom dialog and use returned custom result:

                  private async void ShowDialog_Click(object sender, RoutedEventArgs e)
                  {
                      // Show the custom dialog
                      MyCustomContentDialog dialog = new MyCustomContentDialog();
                      await dialog.ShowAsync();
                  
                      // Use the returned custom result
                      if (dialog.Result == MyResult.Yes)
                      {
                          DialogResult.Text = "Dialog result Yes.";
                      }
                      else if (dialog.Result == MyResult.Cancle)
                      {
                          DialogResult.Text = "Dialog result Canceled.";
                      }
                      else if (dialog.Result == MyResult.No)
                      {
                          DialogResult.Text = "Dialog result NO.";
                      }
                  }
                  

                  Here is the entire sample. Following is the output:

                  这篇关于UWP 中带有 3 个以上按钮的自定义内容对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:使用 MVVM 从 WPF 应用程序启动对话框/子窗口的标准方法 下一篇:在 C# Winform 上使用显示对话框时非常奇怪的错误

                  相关文章

                  • <bdo id='bXsB7'></bdo><ul id='bXsB7'></ul>

                  1. <i id='bXsB7'><tr id='bXsB7'><dt id='bXsB7'><q id='bXsB7'><span id='bXsB7'><b id='bXsB7'><form id='bXsB7'><ins id='bXsB7'></ins><ul id='bXsB7'></ul><sub id='bXsB7'></sub></form><legend id='bXsB7'></legend><bdo id='bXsB7'><pre id='bXsB7'><center id='bXsB7'></center></pre></bdo></b><th id='bXsB7'></th></span></q></dt></tr></i><div id='bXsB7'><tfoot id='bXsB7'></tfoot><dl id='bXsB7'><fieldset id='bXsB7'></fieldset></dl></div>
                      <legend id='bXsB7'><style id='bXsB7'><dir id='bXsB7'><q id='bXsB7'></q></dir></style></legend>
                    1. <small id='bXsB7'></small><noframes id='bXsB7'>

                    2. <tfoot id='bXsB7'></tfoot>