[英]Dialog XAML and Material Design WPF
I am trying to make a dialog popup on a xaml page within my WPF app. 我试图在WPF应用程序内的xaml页面上弹出对话框。 I am using Material Design In XAML Toolkit .
我在XAML Toolkit中使用Material Design 。
The page is within a frame on the main window. 该页面在主窗口的框架内。 I want to make the darkened dialog background go all the way over a menu which in on the main window.
我想使变暗的对话框背景一直遍历主窗口中的菜单。 (Picture Example: Dialog background going over menu and full window )
(图片示例: 对话框背景遍历菜单和全窗口 )
On my page with the button, I have the following code 在带有按钮的页面上,我有以下代码
<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>
Then on my main window, I have the following code: 然后在我的主窗口中,我有以下代码:
<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>
I've also included 我也包括了
xmlns:system="clr-namespace:System;assembly=mscorlib"
When I run the app I have no errors and it opens, but the button named "Popup" is disabled. 当我运行该应用程序时,没有任何错误,它会打开,但是名为“ Popup”的按钮被禁用。 But this code does run and work in the Material Design Demo when I change it there.
但是,当我在此处进行更改时,此代码确实可以在Material Design演示中运行并起作用。
I am new to XAML and this is my first app using this language, so the help would be really appreciated! 我是XAML的新手,这是我使用此语言的第一个应用程序,因此非常感谢您的帮助!
your MainWindow.xaml content should look like this 您的MainWindow.xaml内容应如下所示
<materialDesign:DialogHost Identifier="RootDialog">
<materialDesign:DialogHost.DialogContent>
<!--dialog content-->
</materialDesign:DialogHost.DialogContent>
<Grid>
<!--your window cotnent-->
</Grid>
</materialDesign:DialogHost>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.