我正在尝试在我的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"
当我运行应用程序时,我没有错误并且打开,但是名为"Popup"的按钮被禁用 . 但是当我在那里更改它时,这段代码确实在Material Design Demo中运行并运行 .
我是XAML的新手,这是我第一个使用这种语言的应用程序,所以非常感谢帮助!
1 回答
您的MainWindow.xaml内容应如下所示