【发布时间】:2016-04-12 20:10:16
【问题描述】:
背景
我第一次尝试使用 Mahapps Metro 在 WPF 中构建应用程序。我已按照 Mahapps 快速入门指南 here 中的所有步骤进行操作,但我的结果看起来完全不同(如下所示):
我不确定我还应该尝试什么。我的 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?
【问题讨论】:
-
你能告诉我们你的 MainWindow.xaml 吗?
-
@Pikoh 绝对。
-
好的,尝试将您的
<Window x:Class...更改为<Controls:MetroWindow x:Class.. -
@Pikoh 现在我得到一个编译错误。 'MainWindow' 的部分声明不得指定不同的基类。
-
当然,我忘了警告你。您还必须在
MainWindow.xaml.cs中更改它,而不是MainWindow : Window它必须是MainWindow : MetroWindow他们必须匹配
标签: wpf xaml user-interface user-experience mahapps.metro