How to open a new window click on a menu link in M

2019-08-11 17:36发布

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条回答
forever°为你锁心
2楼-- · 2019-08-11 17:43

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

        }
查看更多
登录 后发表回答