如何在Modern UI wpf中单击菜单链接来打开新窗口? [英] How to open a new window click on a menu link in Modern UI wpf?

查看:283
本文介绍了如何在Modern UI wpf中单击菜单链接来打开新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,每当用户单击菜单链接时,我都想打开一个新窗口. ModernUI菜单链接中没有任何click事件.菜单链接只有一个选项Source.有什么方法可以单击菜单链接来打开新窗口. 菜单链接代码段位于此处:

In my project I want to open a new window whenever the user click on a menu link. There is no click event in ModernUI menu link. The menu link have only one option Source. Is there any way to open a new window clicking on a menu link. Menu link code snippet is here:

<mui:ModernWindow.MenuLinkGroups >
        <mui:LinkGroup DisplayName="File" x:Name="FileMenuGroup" >
            <mui:LinkGroup.Links >
                <mui:Link DisplayName="New Project" Source="/NewProjectUC.xaml"  />
                <mui:Link DisplayName="Open Recent" Source="/RecentItems.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
</mui:ModernWindow.MenuLinkGroups>

推荐答案

我找到了一种在现代窗口中打开新对话的方法. 这是代码 首先创建一个空的UserControl

I had found a way to open a new dialogue in modern window. Here is the code First create an empty UserControl

UserControl.xaml
<UserControl x:Class="ModernUIEDiscovery.NewProjectUC"
            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" 
             mc:Ignorable="d" Height="295" Width="420">

    <Grid></Grid>
</UserControl>

UserControl.xaml.cs

public NewProjectUC()
        {
            InitializeComponent();
            _mainWindow = (MainWindow)Application.Current.MainWindow;

            NewDialog newdialoge = new NewDialog();
            newdialoge.Owner = _mainWindow;
            newdialoge.ShowDialog();

        }

这篇关于如何在Modern UI wpf中单击菜单链接来打开新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆