为 WPF (MUI) 添加与现代 UI 匹配的自定义模态对话框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22451362/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:14:27  来源:igfitidea点击:

Add custom modal dialog matching Modern UI for WPF (MUI)

c#wpfxamlmodern-ui

提问by Dan

I'm using ModernUI for WPF (MUI) available on codeplex here. It's a nice framework and I have no issues using it as a container for my pages.

我使用ModernUI为WPF(MUI)在CodePlex上可用这里。这是一个不错的框架,我将它用作页面的容器没有任何问题。

I'm now trying to add a custom modal dialog, but declaring as a simple Window doesn't keep the nice style MUI has. I've been trying to understand the source code but I can't figure out how to create a window like it does.

我现在正在尝试添加一个自定义模式对话框,但声明为一个简单的 Window 并不能保持 MUI 的漂亮风格。我一直在试图理解源代码,但我不知道如何像它那样创建一个窗口。

Can someone please give me a couple of guidelines on how to achieve a custom modal dialog with this framework?

有人可以给我一些关于如何使用此框架实现自定义模态对话框的指南吗?

EDIT: This is the solution I've found with the help of XAMlMAX:

编辑:这是我在 XAMlMAX 的帮助下找到的解决方案:

<mui:ModernWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:lex="http://wpflocalizeextension.codeplex.com" 
xmlns:SysClient="clr-namespace:SysClient" 
xmlns:System="clr-namespace:System;assembly=mscorlib" 
x:Class="SysClient.Pages.GenericWindow" 
xmlns:mui="http://firstfloorsoftware.com/ModernUI"    
mc:Ignorable="d" Width="800" Height="520" Activated="Window_Activated" Margin="0,0,0,0">
<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/FirstFloor.ModernUI;component/Themes/ModernWindowPopUp.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<Window.Style>
    <StaticResource ResourceKey="ModernWindowPopUp"></StaticResource>
</Window.Style>

And this is how I use it:

这就是我使用它的方式:

  GenericWindow w = new GenericWindow()
  {
      Title = "Add Order",
      ShowInTaskbar = false,               // don't show the dialog on the taskbar
      //Topmost = true,                    // ensure we're Always On Top
      ResizeMode = ResizeMode.NoResize,    // remove excess caption bar buttons
      Owner = Application.Current.MainWindow,
      Tag = new ParametersClass(OrderTypeId),
      ContentSource = new Uri("/Windows/AddOrderWindow.xaml", UriKind.Relative)
  };
  w.ShowDialog();

回答by XAMlMAX

Maybe I know enough to provide an answer: Here is the link to the source code of the markup for the layout: Button templatethis will give you basic understanding of how the application achieves it's look. After you downloaded the dictionaries just apply them to your modal window. And that should be enough to give you desired results :-)

也许我知道的足以提供答案:这是布局标记源代码的链接: 按钮模板这将使您基本了解应用程序如何实现其外观。下载字典后,只需将它们应用到您的模态窗口即可。这应该足以给你想要的结果:-)

Any probs just let us know

任何问题只是让我们知道