![](/img/trans.png)
[英]mahapps:The attachable property 'Flyouts' was not found in type 'MetroWindow'
[英]Mahapps.Metro : The attachable property WindowCommands was not found in type MetroWindow
我以为我会尝试使用Mahapps.Metro尝试一些WPF Metro,并遇到错误:
在MetroWindow类型中找不到可附加的属性WindowCommands
我包括了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();
}
}
}
我试图获得标题栏,就像这里的文档中的标题栏一样。
有任何想法吗?
该代码运行良好,您只是做了一些拼写错误。 更改:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
通过这样:
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
建立您的专案。
您的代码似乎还可以。 添加引用后,您似乎可能尚未构建项目。 此错误仍然存在吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.