简体   繁体   English

Mahapps.Metro:在MetroWindow类型中找不到可附加的属性WindowCommands

[英]Mahapps.Metro : The attachable property WindowCommands was not found in type MetroWindow

I thought i'd try out some WPF Metro using Mahapps.Metro and have come across the error: 我以为我会尝试使用Mahapps.Metro尝试一些WPF Metro,并遇到错误:

The attachable property WindowCommands was not found in type MetroWindow 在MetroWindow类型中找不到可附加的属性WindowCommands

I have included the packages from nuget and have the following xaml: 我包括了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>

and the code behind: 以及后面的代码:

using MahApps.Metro.Controls;

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

I am attempting to get the title bar like the one on the documentation here . 我试图获得标题栏,就像这里的文档中的标题栏一样。

Any ideas? 有任何想法吗?

That code works well, you just did a little misspelling. 该代码运行良好,您只是做了一些拼写错误。 Change that: 更改:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
by that: 通过这样:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />

Build your project. 建立您的专案。

Your code seems OK. 您的代码似乎还可以。 It seems you might have not build your project after the references were added. 添加引用后,您似乎可能尚未构建项目。 Does this error still persist? 此错误仍然存​​在吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM