wpf 如何从代码 (.xaml.cs) 打开材料设计对话框?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49965223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open a material design dialog from the code (.xaml.cs)?
提问by Lotfi
i'm coding a wpf application using material design
我正在使用材料设计编写 wpf 应用程序
i've a DialogHostnamed dialog and i want to open and show its content from the code (.xaml.cs), in XAML the command is Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"but i sought in DialogHost properties and methods and i didn't find anything...
我有一个DialogHost命名对话框,我想从代码 (.xaml.cs) 中打开并显示其内容,在 XAML 中,命令是Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"但我在 DialogHost 属性和方法中寻找,但没有找到任何东西...
回答by Mike
From: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/wiki/Dialogs#dialoghostshow
来自:https: //github.com/ButchersBoy/MaterialDesignInXamlToolkit/wiki/Dialogs#dialoghostshow
var result = await DialogHost.Show(view, "RootDialog", ClosingEventHandler);
var result = await DialogHost.Show(view, "RootDialog", ClosingEventHandler);
If you'd like a concrete example, check out the demo source:
如果您想要一个具体的示例,请查看演示源:
回答by Saad Lembarki
Simply you can use this :
你可以简单地使用这个:
view.IsOpen = true;

