2016-04-12 34 views
0

背景Mahapps地铁发行

我试图建立使用Mahapps地铁的第一次在WPF应用程序。我按照所有的Mahapps快速入门指南here中的步骤,但我的结果看起来完全不同(如下图所示):

Mahapps Screwing Up

我不太确定我应该尝试什么。我的XAML文件与示例完全相同。

这里是我的App.xaml文件看起来像:

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

这里是我的MainWindow.xaml文件看起来像:

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

问题

这里有什么问题,或者它是Mahapps?

+0

你能告诉我们你的MainWindow.xaml吗? – Pikoh

+0

@皮科绝对。 – Snoopy

+1

好吧,尝试改变你的' Pikoh

回答

0

尝试添加以下到您的App.xaml文件:

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

另外,还要确保你在你的MainWindow.xaml改变:

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

,并在您MainWindow.xaml.cs改变基类,而不是MainWindow : Window它必须是MainWindow : MetroWindow

+0

这是他们告诉您在快速入门中要做的确切事情。我已经做到了。 – Snoopy

+0

@StevieV但是你的问题中的代码显示你从'Window'而不是'MetroWindow'派生'MainWindow'。 –

+0

@ThomasFreudenberg是的,这是非常错误的。其中一位用户让我修复这个问题,无论是在评论中还是在这个答案中...... – Snoopy