2016-04-12 6 views
0

HintergrundMahapps Metro Ausgabe

Ich versuche, eine app in WPF Mahapps Metro zum ersten Mal zu bauen. Ich habe alle Schritte in der Mahapps Quick Start Guide gefolgt here, aber meine Ergebnisse völlig anders aussehen (siehe unten):

Mahapps Screwing Up

Ich bin mir nicht ganz sicher, was sonst sollte ich versuchen. Meine XAML-Dateien stimmen genau mit den Beispielen überein. Hier

ist, was meine App.xaml Datei wie folgt aussieht:

<Application x:Class="RxExample.App" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:local="clr-namespace:RxExample" 
     StartupUri="MainWindow.xaml"> 
<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! --> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> 
      <!-- Accent and AppTheme setting --> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

Hier ist, was meine MainWindow.xaml Datei wie folgt aussieht:

<Window x:Class="RxExample.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:local="clr-namespace:RxExample" 
    mc:Ignorable="d" 
    Title="MainWindow" Height="350" Width="525"> 
<Grid> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="368*"/> 
     <ColumnDefinition Width="149*"/> 
    </Grid.ColumnDefinitions> 

</Grid> 

Frage

Was könnte das Problem hier sein, oder ist es Mahapps?

+0

Können Sie uns auch Ihre MainWindow.xaml zeigen? – Pikoh

+0

@Pikoh absolut. – Snoopy

+1

Ok, versuche dein ' Pikoh

Antwort

0

Versuchen Hinzufügen Folgendes zu Ihrer App.xaml Datei:

<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> 
      <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

Auch stellen Sie sicher, dass Sie in Ihrem MainWindow.xaml ändern:

Window x:Class... for <Controls:MetroWindow x:Class..` 

und Ändern von Basisklasse in Ihrem MainWindow.xaml.cs, statt MainWindow : Window muss es MainWindow : MetroWindow

+0

Dies ist genau das, was sie Ihnen im Schnellstart sagen. Ich hab's gemacht. – Snoopy

+0

@StevieV Aber der Code in Ihrer Frage zeigt, dass Sie "MainWindow" von "Window" anstelle von "MetroWindow" ableiten. –

+0

@ThomasFreudenberg Ja, das ist sehr falsch. Einer der Benutzer hat mich das reparieren lassen, entweder in den Kommentaren oder in dieser Antwort ... – Snoopy