【问题标题】:Dialog XAML and Material Design WPF对话框 XAML 和 Material Design WPF
【发布时间】:2018-12-24 10:28:53
【问题描述】:

我正在尝试在我的 WPF 应用程序中的 xaml 页面上弹出一个对话框。我正在使用Material Design In XAML Toolkit

页面位于主窗口的框架内。我想让变暗的对话框背景一直位于主窗口中的菜单上。 (图片示例:Dialog background going over menu and full window

在带有按钮的页面上,我有以下代码

<Button Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}" 
                            Width="128" Grid.Row="3" Grid.Column="1" >
        <Button.CommandParameter>
            <system:DateTime></system:DateTime>
        </Button.CommandParameter>
        Popup
    </Button>

然后在我的主窗口中,我有以下代码:

        <DataTemplate DataType="{x:Type system:DateTime}">
            <StackPanel Margin="16">
                <TextBlock>Example!!</TextBlock>
                <Button  Margin="0 8 0 0" IsDefault="True" Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignRaisedDarkButton}">Close</Button>
            </StackPanel>
        </DataTemplate>
    </ResourceDictionary>
</Window.Resources>

我也加入了

xmlns:system="clr-namespace:System;assembly=mscorlib"

当我运行应用程序时,我没有任何错误并且它打开了,但是名为“弹出”的按钮被禁用。但是当我在Material Design Demo 更改它时,这段代码确实可以在Material Design Demo 中运行和工作。

我是 XAML 的新手,这是我第一个使用这种语言的应用程序,因此非常感谢您的帮助!

【问题讨论】:

    标签: c# wpf xaml material-design material-design-in-xaml


    【解决方案1】:

    您的 MainWindow.xaml 内容应如下所示

     <materialDesign:DialogHost Identifier="RootDialog">
         <materialDesign:DialogHost.DialogContent>
            <!--dialog content-->
        </materialDesign:DialogHost.DialogContent>
         <Grid>
           <!--your window cotnent-->
         </Grid>
     </materialDesign:DialogHost>
    

    【讨论】:

      猜你喜欢
      • 2022-01-17
      • 2017-01-21
      • 2022-08-18
      • 1970-01-01
      • 2014-12-14
      • 2021-01-31
      • 1970-01-01
      • 2022-01-06
      • 1970-01-01
      相关资源
      最近更新 更多