2016-06-17 10 views
0

Ich schreibe eine WPF-Anwendung basierend auf FirtsFloorSoftware Modern UI. Ich habe Probleme, wenn ich versuche, den Inhalt (UserControl) mit 'Source =' in einem Link anzuzeigen. Um das Problem anzuzeigen, habe ich eine kleine separate App erstellt.Modern UI - Modern Menu zeigt keinen Link Inhalt

Das Problem ist, dass der Inhalt von Link 2 (SecondPage.xaml) nie angezeigt wird. Ich habe im Internet nach Hinweisen gesucht, um das Problem zu lösen, aber kein Glück.

Bitte helfen Sie mir.

UPDATE - Added 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> 

Mit freundlichen Grüßen, Fredrik

+0

hilft Können Sie 'MainWindow.xaml' fügen Sie bitte? – SWilko

+0

MainWindow.xaml hinzugefügt, tut mir leid. –

Antwort

0

Auf Ihrer FirstPage.xaml könnten Sie eine ModernTab zB verwenden

<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> 

Alternativ können Sie von First zu NochNeSeite hinter der Verwendung navigieren Code und packt das Frame Objekt. Siehe unten

FirstPage.xaml

<Grid Style="{StaticResource ContentRoot}"> 
    <TextBlock Text="First page" /> 
    <Button x:Name="SecondPageButton" Content="Goto Second Page" Click="SecondPageButton_Click"></Button> 
</Grid? 

Navigieren auf Button-Click-Ereignis 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); 
} 

Hoffnung, die

+0

Ok, Danke. Ich werde das als erstes am Montag versuchen. Ich bin immer noch neugierig, warum das ModernMenu in FirstPage.xaml den Inhalt seines Links (SecondPage.xaml) nicht anzeigt. FirstFloorSoftware hat eine Demo-Anwendung (mit Quellcode) und in dieser Anwendung sind sie in der Lage, was ich versuche zu erreichen. Was mache ich falsch? Link zu Zip mit Demo-App: https://github.com/firstfloorsoftware/mui/releases/download/1.0.8/ModernUI.1.0.8.zip –

+0

Hallo, welches Bit der Demo funktioniert hier wie gewünscht? – SWilko

+0

Link zu Zip mit der neuesten Version: https://github.com/firstfloorsoftware/mui/archive/1.0.9.zip –

Verwandte Themen