Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在一个网格上创建DialogHost并在另一个网格上调用_C#_.net_Wpf_Xaml_Material Design In Xaml - Fatal编程技术网

C# 如何在一个网格上创建DialogHost并在另一个网格上调用

C# 如何在一个网格上创建DialogHost并在另一个网格上调用,c#,.net,wpf,xaml,material-design-in-xaml,C#,.net,Wpf,Xaml,Material Design In Xaml,我想在WPF应用程序中间找到一个使我的对话主机的方法,因为我需要在MigGrase > < /P>中创建它。 <Grid Name="MainGrid"> <materialDesign:DialogHost CloseOnClickAway="True"> <materialDesign:DialogHost.DialogContent> <Grid Margin=&q

我想在WPF应用程序中间找到一个使我的<代码>对话主机的方法,因为我需要在MigGrase<代码> > < /P>中创建它。
<Grid Name="MainGrid">
    <materialDesign:DialogHost CloseOnClickAway="True">
       <materialDesign:DialogHost.DialogContent>
           <Grid Margin="20">
               <TextBlock Text="My first Dialog" />
           </Grid>
       </materialDesign:DialogHost.DialogContent>
   </materialDesign:DialogHost>
   
    <Grid Name="Grid1" Width="250" Height ="Auto">
        ... //MyCode
        <Button Name="MyButton" Style="{StaticResource MaterialDesignRaisedButton}" Click="ButtonClick">
        ...
    </Grid>
</Grid>

... //麦可德
...
但是,我将用于调用此
对话框主机的按钮位于
Grid1

有可能吗?如果是,如何使用?

您可以使用Material Design提供的routed命令。如果将其指定为按钮的
命令
,它将引发一个路由事件,该事件将在可视树中弹出,直到它到达一个
对话框主机
,该主机通过显示对话框来处理它。例如:

<Button Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">

Grid1是一个列,我有几个按钮,图像,文本,字段,复选框,。。。这些Grid1代码在
materialDesign:DialogHost
中会有问题吗?@Michael不会,对话框主机只是作为一个容器,应该不会有任何问题。它是这样设计的,以便您可以从内容中执行open命令,这将引发一个路由事件,只有当
DialogHost
是相应按钮的父按钮时,才能处理该事件。
<Window ...>
   <Grid Name="MainGrid">
      <materialDesign:DialogHost CloseOnClickAway="True">
         <materialDesign:DialogHost.DialogContent>
            <Grid Margin="20">
               <TextBlock Text="My first Dialog" />
            </Grid>
         </materialDesign:DialogHost.DialogContent>
         <Grid Name="Grid1" Width="250" Height ="Auto">
            <Button Name="MyButton"
                    Style="{StaticResource MaterialDesignRaisedButton}"
                    Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
         </Grid>
      </materialDesign:DialogHost>
   </Grid>
</Window>