使用MahApps.Metro在标题栏中显示窗口图标?

时间:2015-01-18 15:45:44

标签: wpf mahapps.metro

我昨天开始使用MahApps.Metro,我无法弄清楚如何让应用程序图标在窗口上显示为窗口图标(或更好,所有这些)。包含示例窗口图标中的Here,但我似乎无法得到它。当我使用

ShowIconOnTitleBar="True"

它没有做任何事情。 我做错了什么?

1 个答案:

答案 0 :(得分:11)

您需要像此示例一样设置Icon属性(取自Mahapps演示应用):

<Controls:MetroWindow x:Class="MetroDemo.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="MahApps.Metro - Demo Application"
        Width="960" Height="600"
        Icon="mahapps.metro.logo2.ico"
        ShowIconOnTitleBar="True"
        ShowTitleBar="True">
    <Grid />
</Controls:MetroWindow>

我建议您下载Mahapps项目的源代码,该项目还包含演示应用程序的源代码(太糟糕了,他们不会在他们的网站上做广告),这非常适合示例。你可以在GitHub上找到它here

相关问题