Skip to content

Commit 1d61342

Browse files
authored
Adding .ico (#1216)
* Add icon * Remove unused code
1 parent cc66e14 commit 1d61342

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed
116 KB
Binary file not shown.

WinUIGallery/Helper/WindowHelper.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
//
99
//*********************************************************
1010

11+
using Microsoft.UI;
12+
using Microsoft.UI.Windowing;
1113
using Microsoft.UI.Xaml;
14+
using System;
1215
using System.Collections.Generic;
16+
using WinRT.Interop;
1317

1418
namespace AppUIBasics.Helper
1519
{
@@ -35,6 +39,13 @@ static public void TrackWindow(Window window)
3539
_activeWindows.Add(window);
3640
}
3741

42+
static public AppWindow GetAppWindow(Window window)
43+
{
44+
IntPtr hWnd = WindowNative.GetWindowHandle(window);
45+
WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd);
46+
return AppWindow.GetFromWindowId(wndId);
47+
}
48+
3849
static public Window GetWindowForElement(UIElement element)
3950
{
4051
if (element.XamlRoot != null)

WinUIGallery/Navigation/NavigationRootPage.xaml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using AppUIBasics.Data;
1818
using AppUIBasics.Helper;
1919
using Microsoft.UI.Dispatching;
20+
using Microsoft.UI.Windowing;
2021
using Microsoft.UI.Xaml;
2122
using Microsoft.UI.Xaml.Automation;
2223
using Microsoft.UI.Xaml.Controls;
@@ -92,10 +93,14 @@ public NavigationRootPage()
9293
Loaded += delegate (object sender, RoutedEventArgs e)
9394
{
9495
NavigationOrientationHelper.UpdateTitleBarForElement(NavigationOrientationHelper.IsLeftMode(), this);
95-
WindowHelper.GetWindowForElement(this).Title = AppTitleText;
96-
var window = WindowHelper.GetWindowForElement(sender as UIElement);
96+
97+
Window window = WindowHelper.GetWindowForElement(sender as UIElement);
98+
window.Title = AppTitleText;
9799
window.ExtendsContentIntoTitleBar = true;
98100
window.SetTitleBar(this.AppTitleBar);
101+
102+
AppWindow appWindow = WindowHelper.GetAppWindow(window);
103+
appWindow.SetIcon("Assets/Tiles/GalleryIcon.ico");
99104
};
100105

101106
NavigationViewControl.RegisterPropertyChangedCallback(NavigationView.PaneDisplayModeProperty, new DependencyPropertyChangedCallback(OnPaneDisplayModeChanged));

WinUIGallery/WinUIGallery.DesktopWap.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<Content Remove="@(Content)" />
8686
</ItemGroup>
8787
<ItemGroup>
88+
<None Remove="Assets\Tiles\GalleryIcon.ico" />
8889
<None Remove="ControlPagesSampleCode\Typography\TypographySample_xaml.txt" />
8990
<None Remove="ControlPages\DesignGuidance\ColorsPage.xaml" />
9091
<None Remove="ControlPages\LinePage.xaml" />
@@ -107,6 +108,7 @@
107108
<Content Include="Assets\HomeHeaderTiles\Header-Toolkit.png" />
108109
<Content Include="Assets\HomeHeaderTiles\Header-WindowsDesign.png" />
109110
<Content Include="Assets\HomeHeaderTiles\Header-WinUIGallery.png" />
111+
<Content Include="Assets\Tiles\GalleryIcon.ico" />
110112
<Content Include="Assets\Tiles\SmallTile-sdk.altform-lightunplated_targetsize-16.png" />
111113
<Content Include="Assets\Tiles\SmallTile-sdk.altform-lightunplated_targetsize-24.png" />
112114
<Content Include="Assets\Tiles\SmallTile-sdk.altform-lightunplated_targetsize-256.png" />

0 commit comments

Comments
 (0)