Kok*_*ads 2 c# wpf mui modern-ui
我目前正在使用CodePlex的Modern UI.它很棒且易于使用,但有一些我不熟悉的课程和活动.示例:我有两个名为"患者"和"配置"的GroupLink.每个GroupLinks都有几个页面.我尝试使用按钮单击事件从一个页面导航到另一个页面.有效.但是当我尝试从GroupLink2的Page1导航到GroupLink1的Page1时,它仍然有效,但问题是活动的GroupLink保留在GroupLink2而不是GroupLink1,就像截图如下所示:


顺便说一句,我用后面的代码从过敏(IrritantPage)导航到PatientsPage:
private void FilterControl_OnToPatientClick(object sender, RoutedEventArgs e)
    {            
        NavigationCommands.GoToPage.Execute("/MainContents/PatientGridPage.xaml", this);
    }
那么我该如何解决这个问题呢?
这是我的MainWindow,患者选项卡页面和配置列表页面
现代窗户(主窗口)
<mui:ModernWindow x:Class="DentalProto.MainWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:mui="http://firstfloorsoftware.com/ModernUI"
                  Title="Dental" IsTitleVisible="True"
                  WindowStartupLocation="CenterScreen"
                  Width="1200"
                  Height="720"                       
                  ContentSource="/Pages/MainTabPage.xaml"
                  Closing="MainWindow_OnClosing"
                  >
    <mui:ModernWindow.MenuLinkGroups>
        <mui:LinkGroup DisplayName="User Name">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="Patients" Source="/Pages/MainTabPage.xaml" />
                <mui:Link DisplayName="Configurations" Source="/Pages/ConfigurationsListNav.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
        <mui:LinkGroup DisplayName="settings" GroupKey="settings">
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="software" Source="/Pages/SettingsPage.xaml" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
    </mui:ModernWindow.MenuLinkGroups>
    <mui:ModernWindow.TitleLinks>
        <mui:Link DisplayName="settings" Source="/Pages/SettingsPage.xaml" />
        <mui:Link DisplayName="help" Source="https://www.facebook.com/" />
    </mui:ModernWindow.TitleLinks>
</mui:ModernWindow>
MAINTAB PAGE(患者页面)
<UserControl x:Class="DentalProto.Pages.MainTabPage"
             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:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="1280">
    <Grid >
        <!-- TODO: set @SelectedSource -->
        <mui:ModernTab Layout="Tab">
            <mui:ModernTab.Links>
                <!-- TODO: set @Source -->
                <mui:Link DisplayName="Patient" Source="/MainContents/PatientGridPage.xaml" />
                <mui:Link DisplayName="Treatment Record" Source="/MainContents/TreatmentFillInPage.xaml"/>
            </mui:ModernTab.Links>
        </mui:ModernTab>
    </Grid>
</UserControl>
CONFIGURATIONLISTNAV(配置页面)
<UserControl x:Class="DentalProto.Pages.ConfigurationsListNav"
             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:mui="http://firstfloorsoftware.com/ModernUI"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid Style="{StaticResource ContentRoot}">
        <!-- TODO: set @SelectedSource -->
        <mui:ModernTab Layout="List">
            <mui:ModernTab.Links>
                <!-- TODO: set @Source -->
                <mui:Link DisplayName="Allergies" Source="/MainContents/IrritantGridPage.xaml"/>
                <mui:Link DisplayName="Health Diseases" Source="/MainContents/HealthDiseaseGridPage.xaml"/>
                <mui:Link DisplayName="Mouth Diseases" Source="/MainContents/MouthDiseaseGridPage.xaml"/>
                <mui:Link DisplayName="Procedures"  Source="/MainContents/ProcedureGridPage.xaml"/>
                <mui:Link DisplayName="Dentists" Source="/MainContents/DentistGridPage.xaml"/>
            </mui:ModernTab.Links>
        </mui:ModernTab>
    </Grid>
</UserControl>
小智 5
您正在将"页面"导航与ModernTab控件内的"选项卡"导航混合.
如果你打电话 NavigationCommands.GoToPage.Execute在ModernTab控件内部,则更改当前的"选项卡",而不是当前的"页面".
要更改顶级页面,您可以使用:
IInputElement target = NavigationHelper.FindFrame("_top", this);
NavigationCommands.GoToPage.Execute("/Pages/BasicPage1.xaml", target);
如果新页面是另一个ModernTab并且您想要选择另一个选项卡然后选择默认选项卡,那么您必须添加一些额外的代码.在示例中,您可以将参数传递给新页面.SE这SO回答.