wpf 使用 MahApps.Metro 在标题栏中显示窗口图标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28011566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show window icon in title bar with MahApps.Metro?
提问by MSmS
I started using MahApps.Metro just yesterday, and I can't figure out how to get application icon to show as window icon on a window (or better, all of them). Herein the example window icon is included, but I can't seem to get it. When I use
我昨天才开始使用 MahApps.Metro,但我不知道如何让应用程序图标显示为窗口上的窗口图标(或者更好,所有这些)。下面的示例窗口图标包括在内,但我似乎无法得到它。当我使用
ShowIconOnTitleBar="True"
it doesn't do anything. What am I doing wrong?
它什么也不做。我究竟做错了什么?
回答by Mickael V.
You need to set the Iconproperty like this example (taken from the Mahapps demo app) :
您需要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>
I suggest that you download the source code for the Mahapps project, which also contains the source for a demo app (too bad they don't advertise it on their website), it's great for examples. You can find it on GitHub here
我建议你下载 Mahapps 项目的源代码,其中还包含一个演示应用程序的源代码(可惜他们没有在他们的网站上做广告),它非常适合作为示例。你可以找到它在GitHub这里

