Skip to content

Commit

Permalink
Adding .ico (#1216)
Browse files Browse the repository at this point in the history
* Add icon

* Remove unused code
  • Loading branch information
niels9001 committed Mar 13, 2023
1 parent cc66e14 commit 1d61342
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Binary file added WinUIGallery/Assets/Tiles/GalleryIcon.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions WinUIGallery/Helper/WindowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
//
//*********************************************************

using Microsoft.UI;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using System;
using System.Collections.Generic;
using WinRT.Interop;

namespace AppUIBasics.Helper
{
Expand All @@ -35,6 +39,13 @@ static public void TrackWindow(Window window)
_activeWindows.Add(window);
}

static public AppWindow GetAppWindow(Window window)
{
IntPtr hWnd = WindowNative.GetWindowHandle(window);
WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd);
return AppWindow.GetFromWindowId(wndId);
}

static public Window GetWindowForElement(UIElement element)
{
if (element.XamlRoot != null)
Expand Down
9 changes: 7 additions & 2 deletions WinUIGallery/Navigation/NavigationRootPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using AppUIBasics.Data;
using AppUIBasics.Helper;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Automation;
using Microsoft.UI.Xaml.Controls;
Expand Down Expand Up @@ -92,10 +93,14 @@ public NavigationRootPage()
Loaded += delegate (object sender, RoutedEventArgs e)
{
NavigationOrientationHelper.UpdateTitleBarForElement(NavigationOrientationHelper.IsLeftMode(), this);
WindowHelper.GetWindowForElement(this).Title = AppTitleText;
var window = WindowHelper.GetWindowForElement(sender as UIElement);

Window window = WindowHelper.GetWindowForElement(sender as UIElement);
window.Title = AppTitleText;
window.ExtendsContentIntoTitleBar = true;
window.SetTitleBar(this.AppTitleBar);

AppWindow appWindow = WindowHelper.GetAppWindow(window);
appWindow.SetIcon("Assets/Tiles/GalleryIcon.ico");
};

NavigationViewControl.RegisterPropertyChangedCallback(NavigationView.PaneDisplayModeProperty, new DependencyPropertyChangedCallback(OnPaneDisplayModeChanged));
Expand Down
2 changes: 2 additions & 0 deletions WinUIGallery/WinUIGallery.DesktopWap.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<Content Remove="@(Content)" />
</ItemGroup>
<ItemGroup>
<None Remove="Assets\Tiles\GalleryIcon.ico" />
<None Remove="ControlPagesSampleCode\Typography\TypographySample_xaml.txt" />
<None Remove="ControlPages\DesignGuidance\ColorsPage.xaml" />
<None Remove="ControlPages\LinePage.xaml" />
Expand All @@ -107,6 +108,7 @@
<Content Include="Assets\HomeHeaderTiles\Header-Toolkit.png" />
<Content Include="Assets\HomeHeaderTiles\Header-WindowsDesign.png" />
<Content Include="Assets\HomeHeaderTiles\Header-WinUIGallery.png" />
<Content Include="Assets\Tiles\GalleryIcon.ico" />
<Content Include="Assets\Tiles\SmallTile-sdk.altform-lightunplated_targetsize-16.png" />
<Content Include="Assets\Tiles\SmallTile-sdk.altform-lightunplated_targetsize-24.png" />
<Content Include="Assets\Tiles\SmallTile-sdk.altform-lightunplated_targetsize-256.png" />
Expand Down

0 comments on commit 1d61342

Please sign in to comment.