Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show window icon in title bar with MahApps.Metro?

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). Here in the example window icon is included, but I can't seem to get it. When I use

ShowIconOnTitleBar="True"

it doesn't do anything. What am I doing wrong?

like image 482
MSmS Avatar asked Jan 18 '15 15:01

MSmS


1 Answers

You need to set the Iconproperty like this example (taken from the Mahapps demo app) :

<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

like image 108
Mickael V. Avatar answered Sep 21 '22 07:09

Mickael V.