我正在编写一个基于FirtsFloorSoftware Modern UI的WPF应用程序。当我试图在链接中显示使用'Source ='设置的内容(UserControl)时,我遇到了问题。为了显示问题,我制作了一个小型的separet应用程序。
问题是链接2(SecondPage.xaml)的内容从未显示。我在互联网上搜索了如何解决这个问题的线索,但没有运气。
请帮帮我。
更新 - 添加了MainWindow.xaml
MainWindow.xaml
<mui:ModernWindow x:Class="TestAvModernMenu.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="mui"
LogoData="F1 M 24.9015,43.0378L 25.0963,43.4298C 26.1685,49.5853 31.5377,54.2651 38,54.2651C 44.4623,54.2651 49.8315,49.5854 50.9037,43.4299L 51.0985,43.0379C 51.0985,40.7643 52.6921,39.2955 54.9656,39.2955C 56.9428,39.2955 58.1863,41.1792 58.5833,43.0379C 57.6384,52.7654 47.9756,61.75 38,61.75C 28.0244,61.75 18.3616,52.7654 17.4167,43.0378C 17.8137,41.1792 19.0572,39.2954 21.0344,39.2954C 23.3079,39.2954 24.9015,40.7643 24.9015,43.0378 Z M 26.7727,20.5833C 29.8731,20.5833 32.3864,23.0966 32.3864,26.197C 32.3864,29.2973 29.8731,31.8106 26.7727,31.8106C 23.6724,31.8106 21.1591,29.2973 21.1591,26.197C 21.1591,23.0966 23.6724,20.5833 26.7727,20.5833 Z M 49.2273,20.5833C 52.3276,20.5833 54.8409,23.0966 54.8409,26.197C 54.8409,29.2973 52.3276,31.8106 49.2273,31.8106C 46.127,31.8106 43.6136,29.2973 43.6136,26.197C 43.6136,23.0966 46.127,20.5833 49.2273,20.5833 Z"
ContentSource="FirstPage.xaml"
>
<mui:ModernWindow.MenuLinkGroups>
<mui:LinkGroup DisplayName="Group 1" >
<mui:LinkGroup.Links>
<mui:Link DisplayName="Link 1" Source="FirstPage.xaml" />
</mui:LinkGroup.Links>
</mui:LinkGroup>
</mui:ModernWindow.MenuLinkGroups>
</mui:ModernWindow>
MainWindow.xaml.cs
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace TestAvModernMenu
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : ModernWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
App.xaml
<Application x:Class="TestAvModernMenu.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.xaml" />
<ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/ModernUI.Light.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
FirstPage.xaml
<UserControl x:Class="TestAvModernMenu.FirstPage"
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"
xmlns:local="clr-namespace:TestAvModernMenu"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" >
<Grid Style="{StaticResource ContentRoot}">
<TextBlock Text="First page" />
<mui:ModernMenu x:Name="mmPatientMenu" Margin="0,40,0,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<mui:ModernMenu.LinkGroups>
<mui:LinkGroup DisplayName="Group 2">
<mui:LinkGroup.Links>
<mui:Link DisplayName="Link 2" Source="SecondPage.xaml"></mui:Link>
</mui:LinkGroup.Links>
</mui:LinkGroup>
</mui:ModernMenu.LinkGroups>
</mui:ModernMenu>
</Grid>
</UserControl>
SecondPage.xaml
<UserControl x:Class="TestAvModernMenu.SecondPage"
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:local="clr-namespace:TestAvModernMenu"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Style="{StaticResource ContentRoot}">
<TextBlock Text="Second page" />
</Grid>
</UserControl>
祝你好运, 弗雷德里克
答案 0 :(得分:0)
在FirstPage.xaml
上,您可以使用ModernTab
例如
<StackPanel Style="{StaticResource ContentRoot}">
<TextBlock Text="First page" />
<mui:ModernTab Layout="List">
<mui:ModernTab.Links>
<mui:Link Source="/SecondPage.xaml" DisplayName="Second Page"></mui:Link>
</mui:ModernTab.Links>
</mui:ModernTab>
</StackPanel>
或者,您可以使用后面的代码从FirstPage导航到SecondPage并抓取Frame
对象。见下文
FirstPage.xaml
<Grid Style="{StaticResource ContentRoot}">
<TextBlock Text="First page" />
<Button x:Name="SecondPageButton" Content="Goto Second Page" Click="SecondPageButton_Click"></Button>
</Grid?
导航按钮点击事件 FirstPage.xaml.cs
private void SecondPageButton_Click(object sender, RoutedEventArgs e)
{
var frame = FirstFloor.ModernUI.Windows.Navigation.NavigationHelper.FindFrame(null, this);
if (frame != null)
frame.Source = new Uri("/SecondPage.xaml", UriKind.Relative);
}
希望有所帮助