0

Mahapps.Metroを使用して WPF Metro を試してみようと思ったのですが、次のエラーに遭遇しました。

添付可能なプロパティ WindowCommands がタイプ 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のようなタイトル バーを取得しようとしています。

何か案は?

4

2 に答える 2

2

このコードはうまく機能します。スペルを少し間違えただけです。それを変更してください:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
それによって:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />

于 2014-03-12T10:06:58.957 に答える
1

プロジェクトをビルドします。

あなたのコードは問題ないようです。参照が追加された後、プロジェクトをビルドしていないようです。このエラーは引き続き発生しますか?

于 2012-07-02T21:05:47.137 に答える