2012-06-06 38 views
0

我想我會嘗試一些WPF地鐵使用Mahapps.Metro和所遇到的錯誤:Mahapps.Metro:的附着性能WindowCommands中未發現型MetroWindow

The attachable property WindowCommands was not found in type MetroWindow

我已經包括了從的NuGet包並具有以下XAML:

<Controls:MetroWindow x:Class="WpfApplication1.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" 
     Title="MainWindow" Height="350" Width="525"> 
    <Window.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" /> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> 
       <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.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> 
    </Window.Resources> 
    <Controls:MetroWindow.WindowCommands> 
     <Controls:WindowCommands> 
      <Button Content="settings" /> 
     </Controls:WindowCommands> 
    </Controls:MetroWindow.WindowCommands> 


    <Controls:MetroContentControl> 
     <Button Content="Blah" Height="20" Width="150" /> 
    </Controls:MetroContentControl> 
</Controls:MetroWindow> 

和後面的代碼:

using MahApps.Metro.Controls; 

namespace WpfApplication1 
{ 
    /// <summary> 
    /// Interaction logic for MainWindow.xaml 
    /// </summary> 
    public partial class MainWindow : MetroWindow 
    { 
     public MainWindow() 
     { 
      InitializeComponent(); 
     } 
    } 
} 

我試圖獲得標題欄,如文檔here上的標題欄。

任何想法?

回答

1

建立你的項目。

你的代碼似乎沒問題。看來你可能還沒有建立你的項目後添加引用。 此錯誤是否仍然存在?

+0

它似乎在我的其他電腦的工作是如此想,我是VS borked(unsupprisingly) –

2

該代碼運行良好,您只是做了一點拼寫錯誤。 更改是:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
由:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />

相關問題