How to open a new window click on a menu link in Modern UI wpf?

删除回忆录丶 提交于 2019-12-11 13:48:29

问题


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>

回答1:


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();

        }


来源:https://stackoverflow.com/questions/25758483/how-to-open-a-new-window-click-on-a-menu-link-in-modern-ui-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!