Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding .ico #1216

Merged
merged 2 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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