簡體   English   中英

如何在Modern UI wpf中單擊菜單鏈接來打開新窗口?

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

在我的項目中,每當用戶單擊菜單鏈接時,我都想打開一個新窗口。 ModernUI菜單鏈接中沒有click事件。 菜單鏈接只有一個選項Source 有什么方法可以單擊菜單鏈接來打開新窗口。 菜單鏈接代碼段位於此處:

<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

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

        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM