Code Monkey home page Code Monkey logo

winuicommunity's Introduction

dotnet OS IDE-version githubrepo-size
Projects Packages
releaseDate license Docs build

Packages Download/Installation Documentation
Visual Studio Marketplace Version Marketplace Document
NuGet Version NuGet Download Document
NuGet Version NuGet Download Document
NuGet Version NuGet Download Document
NuGet Version NuGet Download Document
NuGet Version NuGet Download Document

🌟 Support My Work! 🌟

Important

🌟 I pour my heart and soul into creating useful apps and tools. If you’ve found my work helpful or interesting, consider supporting me by making a donation. 🌟

Trust Wallet Address
Bitcoin bc1qzs4kt4aeqym6gsde669g5rksv4swjhzjqqp23a
ETH 0x40Db4476c1D498b167f76A2c7ED9D45b65eb5d0C

πŸš€ WinUICommunity πŸš€

Welcome to WinUICommunity Core, your go-to toolkit for building WinUI 3 applications with ease. Whether you’re a seasoned developer or just starting out, we’ve got you covered! πŸŽ‰

WinUICommunity is a collection of useful classes, controls, styles, and codes for WinUI 3, the modern native UI platform for Windows 10+. With WinUICommunity, you can:

  • ✨ Create a WinUI 3 app in less than a minute with the built-in project templates and scaffolding tools.
  • ✨ Customize the appearance of your app with various themes, such as rainbow, dark, light, and more.
  • ✨ Enhance your UI with custom controls.
  • ✨ Leverage the power of Win2D, a DirectX-based graphics library for WinUI, to create stunning effects, such as particle, gooey, watermark, etc.
  • ✨ Access native Windows APIs from your WinUI app with the PInvoke helper class.
  • ✨ Simplify common tasks, such as navigation, theme, update, notification, etc. with the helper classes and extensions.

πŸ“š Explore Our Documentation! πŸ“š

Tip

Need help getting started with our app? Our comprehensive documentation site covers everything you need to know. Whether you’re a beginner or an experienced user, you’ll find answers, tutorials, and tips to enhance your experience. From installation instructions to advanced features, we’ve got you covered. Happy exploring! πŸš€ πŸ‘‰ Documentation πŸ‘ˆ

πŸš€ Explore Our Gallery App πŸš€

Note

Want to see WinUICommunity in action? Head over to our Gallery App for a hands-on experience. You’ll find practical examples, usage scenarios, and interactive demos that showcase the power of our toolkit. See Galery App Source Code or Download from Microsoft Store.

πŸ§‘β€πŸ’» Contributing πŸ§‘β€πŸ’»

Found a bug? Want to contribute? We’d love your input! Happy coding! πŸ–₯οΈπŸ’‘


πŸ”₯ Core πŸ”₯

Experience WinUI 3 quickly and easily with the help of Core, Everything you need to develop an application is gathered in one place. Helpers, Extensions...

⚑ What’s Inside? ⚑

  • ✨ Converter
  • ✨ DynamicLanguage
  • ✨ Extensions
  • ✨ Helpers
  • ✨ NavigationService
  • ✨ RainbowFrame
  • ✨ ThemeService
  • ✨ PickCredential
  • ✨ RequestWindowsPIN
  • πŸš€ And More...

πŸ’» Installation | Nuget

Install-Package WinUICommunity.Core

Warning

For more info See the Core and Docs


πŸ”₯ Components πŸ”₯

Experience WinUI 3 quickly and easily with the help of Components, Everything you need to develop an application is gathered in one place. Components Includes custom controls and styles.

⚑ What’s Inside? ⚑

  • ✨ SelectorBarSegmented
  • ✨ NavigationViewItem Style
  • ✨ ColorfulShimmingEffect
  • ✨ FlipSide
  • ✨ LongShadowTextBlock
  • ✨ PagerControl [It will be removed with the release of WASDK v1.5]
  • ✨ IndeterminateProgressBar
  • ✨ LoadingIndicator
  • ✨ AutoScrollView
  • ✨ OpacityMaskView
  • ✨ ProgressRing
  • ✨ WaveProgressBar
  • ✨ Divider
  • ✨ Shield
  • ✨ Gravatar
  • ✨ FlyoutMenuButton
  • ✨ Growl
  • ✨ InlineAutoCompleteTextBox
  • ✨ IsEnabledTextBlock
  • ✨ KeyVisual
  • ✨ OOBEPageControl
  • ✨ Shortcut
  • ✨ Validation
  • ✨ WrapPanel
  • ✨ CheckBoxWithDescription
  • ✨ OptionsPageControl
  • ✨ TitleBar
  • ✨ SettingsCard
  • ✨ SettingsExpander
  • ✨ SettingsGroup
  • ✨ SwitchPresenter
  • ✨ UniformGrid
  • ✨ InfoBar Style
  • ✨ Grid Style
  • ✨ StackPanel Style
  • ✨ Border Style
  • ✨ Subtle Button Style

πŸ’» Installation | Nuget

Install-Package WinUICommunity.Components

After installing, add the following resource to app.xaml

<ResourceDictionary Source="ms-appx:///WinUICommunity.Components/Themes/Generic.xaml" />

Warning

For more info See the Components and Docs


πŸ”₯ Win2D πŸ”₯

Experience WinUI 3 quickly and easily with the help of Win2D Components, Everything you need to develop an application is gathered in one place. Win2d Includes custom controls and styles.

⚑ What’s Inside? ⚑

  • ✨ TiledImageBrush
  • ✨ OutlineTextControl
  • ✨ WaveCircle
  • ✨ BlurAnimationHelper
  • ✨ Watermark
  • ✨ TextMorphEffect
  • ✨ TextGlitchEffect
  • ✨ TextBlockStrokeView
  • ✨ Particle
  • ✨ BubbleButton
  • ✨ BubbleProgressButton
  • ✨ GooeyFooterEffect
  • ✨ GooeyEffect
  • ✨ GooeyButton

πŸ’» Installation | Nuget

Install-Package WinUICommunity.Win2D

After installing, add the following resource to app.xaml

<ResourceDictionary Source="ms-appx:///WinUICommunity.Win2D/Themes/Generic.xaml" />

Warning

For more info See the Win2D and Docs


πŸ”₯ LandingPages πŸ”₯

Create a landing page in the style of WinUI 3 and WinUI-Gallery very quickly and easily

⚑ What’s Inside? ⚑

  • ✨ HomeLandingPage
  • ✨ AllLandingPage

πŸ’» Installation | Nuget

Install-Package WinUICommunity.LandingPages

After installing, add the following resource to app.xaml

<wuc:ItemTemplates/>
<ResourceDictionary Source="ms-appx:///WinUICommunity.LandingPages/Themes/Generic.xaml" />

Warning

For more info See the LandingPages and Docs


πŸ”₯ ContextMenuExtensions πŸ”₯

add a new ContextMenu for Windows 11/10.

πŸ’» Installation | Nuget

Install-Package WinUICommunity.ContextMenuExtensions

Warning

For more info See the ContextMenuExtensions and Docs


πŸ₯· Project Templates πŸ₯·

Tip

πŸ”₯ Create a new project easily with your custom options, you can use our project templates and wizard! Download and install our VSIX extension from Marketplace

WinUICommunity

WinUICommunityTemplates


History

SelectorBarSegmented / Experimental

WinUICommunity

NavigationViewItem Style

WinUICommunity

ColorfulShimmingEffect

WinUICommunity

TiledImageBrush /Win2d

WinUICommunity

OutlineTextControl /Win2d

WinUICommunity

FlipSide

WinUICommunity

LongShadowTextBlock

WinUICommunity

PickCredential

WinUICommunity

RequestWindowsPIN

WinUICommunity

PagerControl

It will be removed with the release of WASDK v1.6

WinUICommunity

IndeterminateProgressBar

WinUICommunity

LoadingIndicator

WinUICommunity

ThemeService / Backdrop TintColor

WinUICommunity

OpacityMaskView

WinUICommunity WinUICommunity

AutoScrollView

WinUICommunity WinUICommunity

ProgressRing

WinUICommunity

WaveProgressBar

WinUICommunity

Watermark /Win2d

WinUICommunity WinUICommunity

BlurAnimationHelper /Win2d

WinUICommunity

GooeyButton /Win2d

WinUICommunity

GooeyEffect /Win2d

WinUICommunity

GooeyFooterEffect /Win2d

WinUICommunity

WaveCircle /Win2d

WinUICommunity

Bubble /Win2d

WinUICommunity

Particle /Win2d

WinUICommunity

TextBlockStrokeView /Win2d

WinUICommunity

TextGlitchEffect /Win2d

WinUICommunity

TextMorphEffect /Win2d

WinUICommunity

TitleBar

WinUICommunity WinUICommunity WinUICommunity

FontIcon Extension : Choose Fluent Icons (more than 1400) with Name or Code

WinUICommunity WinUICommunity

Divider

WinUICommunity

Shield

WinUICommunity

Gravatar

WinUICommunity

Growl

WinUICommunity

Transparent Backdrop

WinUICommunity

Acrylic Backdrop

WinUICommunity WinUICommunity

Options Page Control

WinUICommunity

ContextMenu

WinUICommunity

SwitchPresenter

WinUICommunity

Blue InfoBar

WinUICommunity

Border Style

WinUICommunity

StackPanel Style

WinUICommunity

Grid Style

WinUICommunity

Settings

WinUICommunity WinUICommunity WinUICommunity

AutoSuggestBox Helper

WinUICommunity

Enum Value Extension

WinUICommunity

Picker

WinUICommunity

TextBox Extension

WinUICommunity WinUICommunity

Validation

WinUICommunity

AppNotification

WinUICommunity

CheckBox With Description Control

WinUICommunity

Hyperlink Button Style

WinUICommunity

Inline AutoComplete

WinUICommunity

TextBox Checked

WinUICommunity

KeyVisual

WinUICommunity

ListViewItem Setting Style

WinUICommunity

NavigationView Service

WinUICommunity

Shortcut

WinUICommunity WinUICommunity

TabViewItem Style

WinUICommunity

Taskbar Helper

WinUICommunity

LandingPages

WinUICommunity

WinUICommunity

WinUICommunity

WinUICommunity

WinUICommunity

WinUICommunity

Settings

WinUICommunity

WinUICommunity

WinUICommunity

WinUICommunity

WinUICommunity

WinUICommunity

winuicommunity's People

Contributors

damix48 avatar ghost1372 avatar jeremywu917 avatar lanhuangjg avatar poker-sang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

winuicommunity's Issues

6.1.0 Has some problems

Hi, it's me again.

Published Demo app is broken:

Spoiler

DEMO APP

Theme service makes my app crash:

var themeService = App.GetService<IThemeService>();
themeService.Initialize(App.MainWindow, false);
themeService.ConfigElementTheme(ElementTheme.Default);
themeService.ConfigBackdrop(BackdropType.Mica);

App will start as usual and works fine. I my settings page I don't register combo box but use my methods where I try to set theme like this:

var theme = ThemeIndex switch
{
    0 => ElementTheme.Light,
    1 => ElementTheme.Dark,
   _ => ElementTheme.Default
};

if (theme == _themeService.GetElementTheme())
    return;

_themeService.SetElementTheme(theme);

using _themeService.SetElementTheme(theme); will lead to app crash

Exception
Parameter is not correct.
target

Stack trace:

   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|39_0(Int32 hr)
   at ABI.Microsoft.UI.Xaml.Media.ISystemBackdropOverridesMethods.OnDefaultSystemBackdropConfigurationChanged(IObjectReference _obj, ICompositionSupportsSystemBackdrop target, XamlRoot xamlRoot)
   at Microsoft.UI.Xaml.Media.SystemBackdrop.OnDefaultSystemBackdropConfigurationChanged(ICompositionSupportsSystemBackdrop target, XamlRoot xamlRoot)
   at Microsoft.UI.Xaml.Media.SystemBackdrop.Microsoft.UI.Xaml.Media.ISystemBackdropOverrides.OnDefaultSystemBackdropConfigurationChanged(ICompositionSupportsSystemBackdrop target, XamlRoot xamlRoot)
   at ABI.Microsoft.UI.Xaml.Media.ISystemBackdropOverrides.Do_Abi_OnDefaultSystemBackdropConfigurationChanged_2(IntPtr thisPtr, IntPtr target, IntPtr xamlRoot)

I found if configuting/setting first time to Backdroptype to None and after set it to mica or other changing theme will work fine.

I still have question about titlebar buttons. Yes changing theme in windows will work fine.

Spoiler

AUTO THEME

But changing theme via Themeservice will not change button foreground till I use your titlebar + AppTitleBar.Window = App.MainWindow;

Spoiler

kek

Is this intended to work like this?

Cannot change shortcut

image
pressing buttons doesn't change anything, this is from the demo app.
looking at the code there is nothing written to update, even though the UI says it can.

[SUGGESTION] TitleBar Improvements

The caption buttons do not respond to theme changes unless we utilize WinuiCommunity.Titlebar as the title bar. Is it feasible to segregate these two features so that the ThemeService manages all color modifications? Additionally, I would like to add width and margin properties to the Back/Toggle button. For instance, my NavView's CompactPaneLength is set to 60, but the back button appears too small and doesn't look good. I am currently addressing this issue by overriding the style. Here's an example:

<winuicommunity:TitleBar.Resources>
   <Style x:Key="TitleBarBackButtonStyle" TargetType="Button">
       <Setter Property="Width" Value="60" />
       ...................................................................................
   </Style>
</winuicommunity:TitleBar.Resources>

Thank you.

[BUG] The drag region in TitleBar control blocks clicking on PART_PaneButton

Expected result:
image

Actual result:
image

I suggest using the following fix:

Author: Dmitry Zhukovsky <[email protected]>  2023-11-04 00:05:06
Committer: Dmitry Zhukovsky <[email protected]>  2023-11-04 00:05:06
Parent: b168d78e9ce74e96a4adfc6de1d644d1376b53a8 (Update Localizer.cs)
Branch: main
Follows: v5.3.1
Precedes: 

    Fixed the drag region in the TitleBar that was causing the PaneButton to be unclickable.

-------------- dev/Components/Controls/Labs/TitleBar/TitleBar.cs --------------
index 5ee9c25..8b8c07c 100644
@@ -24,6 +24,7 @@ namespace WinUICommunity;
 [TemplatePart(Name = PartPaneButton, Type = typeof(Button))]
 [TemplatePart(Name = nameof(PART_LeftPaddingColumn), Type = typeof(ColumnDefinition))]
 [TemplatePart(Name = nameof(PART_RightPaddingColumn), Type = typeof(ColumnDefinition))]
+[TemplatePart(Name = nameof(PART_ButtonHolder), Type = typeof(StackPanel))]
 
 public partial class TitleBar : Control
 {
@@ -64,6 +65,7 @@ public partial class TitleBar : Control
 
     ColumnDefinition? PART_LeftPaddingColumn;
     ColumnDefinition? PART_RightPaddingColumn;
+    StackPanel? PART_ButtonHolder;
 
     public TitleBar()
     {
@@ -75,6 +77,7 @@ public partial class TitleBar : Control
         PART_LeftPaddingColumn = GetTemplateChild(nameof(PART_LeftPaddingColumn)) as ColumnDefinition;
         PART_RightPaddingColumn = GetTemplateChild(nameof(PART_RightPaddingColumn)) as ColumnDefinition;
         Configure();
+        ConfigureButtonHolder();
         if (GetTemplateChild(PartBackButton) is Button backButton)
         {
             backButton.Click -= BackButton_Click;
@@ -122,6 +125,26 @@ public partial class TitleBar : Control
         PaneButtonClick?.Invoke(this, new RoutedEventArgs());
     }
 
+    private void ConfigureButtonHolder()
+    {
+        if (PART_ButtonHolder != null)
+        {
+            PART_ButtonHolder.SizeChanged -= PART_ButtonHolder_SizeChanged;
+        }
+
+        PART_ButtonHolder = GetTemplateChild(nameof(PART_ButtonHolder)) as StackPanel;
+
+        if(PART_ButtonHolder != null)
+        {
+            PART_ButtonHolder.SizeChanged += PART_ButtonHolder_SizeChanged;
+        }
+    }
+
+    private void PART_ButtonHolder_SizeChanged(object sender, SizeChangedEventArgs e)
+    {
+        SetDragRegionForCustomTitleBar();
+    }
+
     private void Configure()
     {
         SetWASDKTitleBar();

------------- dev/Components/Controls/Labs/TitleBar/TitleBar.xaml -------------
index 08f9651..61e01c5 100644
@@ -166,7 +166,7 @@
                               Grid.Column="2"
                               Grid.ColumnSpan="6"
                               Background="Transparent" />
-                        <StackPanel x:Name="ButtonHolder"
+                        <StackPanel x:Name="PART_ButtonHolder"
                                     Grid.Column="1"
                                     Orientation="Horizontal">
                             <Button x:Name="PART_BackButton"

---------------------- dev/Components/Themes/Generic.xaml ----------------------
index 97a1493..877fb1e 100644
@@ -2191,7 +2191,7 @@ Themes\Styles\TextBlock.xaml
               <win:TextBlock x:Name="PART_SubtitleText" MinWidth="48" Margin="0,0,0,1" FontFamily="{ThemeResource ContentControlThemeFontFamily}" Foreground="{ThemeResource TextFillColorSecondaryBrush}" Style="{StaticResource CaptionTextBlockStyle}" Text="{TemplateBinding Subtitle}" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" />
             </win:StackPanel>
             <win:Grid x:Name="PART_DragRegion" Grid.Column="2" Grid.ColumnSpan="6" Background="Transparent" />
-            <win:StackPanel x:Name="ButtonHolder" Grid.Column="1" Orientation="Horizontal">
+            <win:StackPanel x:Name="PART_ButtonHolder" Grid.Column="1" Orientation="Horizontal">
               <win:Button x:Name="PART_BackButton" Style="{ThemeResource TitleBarBackButtonStyle}" ToolTipService.ToolTip="Back" />
               <win:Button x:Name="PART_PaneButton" Style="{StaticResource TitleBarPaneToggleButtonStyle}" ToolTipService.ToolTip="Toggle menu" />
             </win:StackPanel>

[Feature] Implement Navigation Frame with Dependency Injection for Enhanced Navigation

Description

I would like to propose a new feature that integrates Dependency Injection (DI) directly into pages to facilitate smoother interaction with the NavigationService and to enable the seamless passing of various types of parameters between pages. This could include anything from record IDs to custom service implementations.

Motivation

The main goal of this feature is to enhance the usability of the NavigationService by leveraging DI, thus simplifying the process of parameter passing and service management during navigation. This approach would make it more convenient to work with complex dependencies and parameters within our navigation framework.

Proposed Solution

Implement a Navigation Frame that incorporates DI to allow for:

  • Direct injection of services into pages.
  • Easy parameter passing between pages with support for various data types.

Implementation Details

Here is a preliminary example of how this can be implemented in WinUI 3 and .NET 8:
(to build the project, please use the *.nupkg files located in the root of the archive)

DemoApp.zip

Using the HomeLandingPage in unpackaged app crashes

Hello, When I am publishing my app as unpackaged and starting it I notice it crashing straight away. If I take out the MainLandingPage or AllLandingPage and publish it the app works just fine. When I am taking out the HomeLandingPage or set a other page as default to start it works but I am than missing my sidebar items.

image

[BUG] Drag regions in the TitleBar control calculated Incorrectly

For clarity, I added a minimum width and color for each TitleBar element:

image

Π’his is what it looks like:

image

Problem 1

PART_RootGrid has Padding.Right causing the window button area to move to the right:
image

Fix

Set Padding="4,0,0,0" for PART_RootGrid:
https://github.com/WinUICommunity/WinUICommunity/blob/b959f0342c129db75d0370ac42c7f9ccf5c1bf5e/dev/Components/Controls/Labs/TitleBar/TitleBar.xaml#L21C33-L21C33

Problem 2

Due to PART_RootGrid.Padding.Left regions are calculated incorrectly:
https://github.com/WinUICommunity/WinUICommunity/assets/136100876/148de3cd-9a70-49b5-a87a-a6f4ca2331e2

Fix

Fix SetDragRegionForCustomTitleBar method.
Plus (+) is draggable area, minus (-) is non-draggable area.

+[rootGrid.padding.left][leftPadding]
-[buttonsHolder]
+[icon][title][leftDrag]
-[content]
+[rightDrag]
-[footer]
+[rightPadding][rootGrid.padding.right]            

I after applying fix, it will look like this:
https://github.com/WinUICommunity/WinUICommunity/assets/136100876/4637e586-82a4-4266-9553-ee1566b238b3

private void SetDragRegionForCustomTitleBar()
{
    if (AutoConfigureCustomTitleBar && Window != null && PART_RightPaddingColumn != null && PART_LeftPaddingColumn != null)
    {
        double scaleAdjustment = GetScaleAdjustment();

        PART_RightPaddingColumn.Width = new GridLength(Window.AppWindow.TitleBar.RightInset / scaleAdjustment);
        PART_LeftPaddingColumn.Width = new GridLength(Window.AppWindow.TitleBar.LeftInset / scaleAdjustment);

        var height = (int)(this.ActualHeight * scaleAdjustment);
        Windows.Graphics.RectInt32 rect1 = new(0, 0, 0, height);
        Windows.Graphics.RectInt32 rect2 = new(0, 0, 0, height);
        Windows.Graphics.RectInt32 rect3 = new(0, 0, 0, height);
        Windows.Graphics.RectInt32 rect4 = new(0, 0, 0, height);

        rect1.X = 0;
        rect1.Width = (int)((PART_RootGrid.Padding.Left
                            + PART_LeftPaddingColumn.ActualWidth)
                            * scaleAdjustment);

        rect2.X = rect1.X + rect1.Width + (int)((PART_ButtonsHolderColumn.ActualWidth) * scaleAdjustment);
        rect2.Width = (int)((PART_IconColumn.ActualWidth
                            + PART_TitleColumn.ActualWidth
                            + PART_LeftDragColumn.ActualWidth)
                            * scaleAdjustment);

        rect3.X = rect2.X + rect2.Width + (int)(PART_ContentColumn.ActualWidth * scaleAdjustment);
        rect3.Width = (int)(PART_RightDragColumn.ActualWidth * scaleAdjustment);

        rect4.X = rect3.X + rect3.Width + (int)((PART_FooterColumn.ActualWidth
                                                + PART_RightPaddingColumn.ActualWidth
                                                + PART_RootGrid.Padding.Right)
                                                * scaleAdjustment);
        rect4.Width = (int)(PART_RightPaddingColumn.ActualWidth * scaleAdjustment);

        Windows.Graphics.RectInt32[] dragRects = new[] { rect1, rect2, rect3, rect4 };
        Window.AppWindow.TitleBar.SetDragRectangles(dragRects);
    }
}

Patch

Author: Dmitry Zhukovsky <[email protected]>  2023-11-04 17:51:03
Committer: Dmitry Zhukovsky <[email protected]>  2023-11-04 17:51:03
Parent: b959f0342c129db75d0370ac42c7f9ccf5c1bf5e (Fix #8 Tnx to @dzhukovsky)
Branch: main
Follows: v5.3.1
Precedes: 

    Fix drag regions calculation in the TitleBar control.

----------- dev/Components/Controls/Labs/TitleBar/TitleBar.WASDK.cs -----------
index 3d16fe6..b9b628a 100644
@@ -17,6 +17,7 @@ namespace WinUICommunity;
 [TemplatePart(Name = nameof(PART_FooterColumn), Type = typeof(ColumnDefinition))]
 [TemplatePart(Name = nameof(PART_RightDragColumn), Type = typeof(ColumnDefinition))]
 [TemplatePart(Name = nameof(PART_TitleHolder), Type = typeof(StackPanel))]
+[TemplatePart(Name = nameof(PART_RootGrid), Type = typeof(Grid))]
 
 public partial class TitleBar : Control
 {
@@ -28,6 +29,7 @@ public partial class TitleBar : Control
     ColumnDefinition? PART_FooterColumn;
     ColumnDefinition? PART_RightDragColumn;
     StackPanel? PART_TitleHolder;
+    Grid? PART_RootGrid;
 
     private void SetWASDKTitleBar()
     {
@@ -41,7 +43,7 @@ public partial class TitleBar : Control
             Window.AppWindow.TitleBar.ExtendsContentIntoTitleBar = true;
 
             ConfigPresenter();
-            
+
             this.Window.Activated -= Window_Activated;
             this.Window.Activated += Window_Activated;
 
@@ -63,6 +65,7 @@ public partial class TitleBar : Control
             PART_RightDragColumn = GetTemplateChild(nameof(PART_RightDragColumn)) as ColumnDefinition;
             PART_FooterColumn = GetTemplateChild(nameof(PART_FooterColumn)) as ColumnDefinition;
             PART_TitleHolder = GetTemplateChild(nameof(PART_TitleHolder)) as StackPanel;
+            PART_RootGrid = GetTemplateChild(nameof(PART_RootGrid)) as Grid;
 
             // Get caption button occlusion information.
             int CaptionButtonOcclusionWidthRight = Window.AppWindow.TitleBar.RightInset;
@@ -137,35 +140,33 @@ public partial class TitleBar : Control
             PART_RightPaddingColumn.Width = new GridLength(Window.AppWindow.TitleBar.RightInset / scaleAdjustment);
             PART_LeftPaddingColumn.Width = new GridLength(Window.AppWindow.TitleBar.LeftInset / scaleAdjustment);
 
-            List<Windows.Graphics.RectInt32> dragRectsList = new();
-
-            Windows.Graphics.RectInt32 dragRectL;
-            dragRectL.X = (int)((PART_LeftPaddingColumn.ActualWidth
-                            + PART_ButtonsHolderColumn!.ActualWidth)
-                            * scaleAdjustment);
-            dragRectL.Y = 0;
-            dragRectL.Height = (int)(this.ActualHeight * scaleAdjustment);
-            dragRectL.Width = (int)((PART_IconColumn!.ActualWidth
-                                + PART_TitleColumn!.ActualWidth
-                                + PART_LeftDragColumn!.ActualWidth)
+            var height = (int)(this.ActualHeight * scaleAdjustment);
+            Windows.Graphics.RectInt32 rect1 = new(0, 0, 0, height);
+            Windows.Graphics.RectInt32 rect2 = new(0, 0, 0, height);
+            Windows.Graphics.RectInt32 rect3 = new(0, 0, 0, height);
+            Windows.Graphics.RectInt32 rect4 = new(0, 0, 0, height);
+
+            rect1.X = 0;
+            rect1.Width = (int)((PART_RootGrid.Padding.Left
+                                + PART_LeftPaddingColumn.ActualWidth)
                                 * scaleAdjustment);
-            dragRectsList.Add(dragRectL);
-
-            Windows.Graphics.RectInt32 dragRectR;
-            dragRectR.X = (int)((PART_LeftPaddingColumn.ActualWidth
-                                + PART_IconColumn.ActualWidth
-                                + PART_ButtonsHolderColumn!.ActualWidth
-                                + PART_TitleHolder!.ActualWidth
-                                + PART_LeftDragColumn.ActualWidth
-                                + PART_ContentColumn!.ActualWidth)
+
+            rect2.X = rect1.X + rect1.Width + (int)((PART_ButtonsHolderColumn.ActualWidth) * scaleAdjustment);
+            rect2.Width = (int)((PART_IconColumn.ActualWidth
+                                + PART_TitleColumn.ActualWidth
+                                + PART_LeftDragColumn.ActualWidth)
                                 * scaleAdjustment);
-            dragRectR.Y = 0;
-            dragRectR.Height = (int)(this.ActualHeight * scaleAdjustment);
-            dragRectR.Width = (int)(PART_RightDragColumn!.ActualWidth * scaleAdjustment);
-            dragRectsList.Add(dragRectR);
 
-            Windows.Graphics.RectInt32[] dragRects = dragRectsList.ToArray();
+            rect3.X = rect2.X + rect2.Width + (int)(PART_ContentColumn.ActualWidth * scaleAdjustment);
+            rect3.Width = (int)(PART_RightDragColumn.ActualWidth * scaleAdjustment);
+
+            rect4.X = rect3.X + rect3.Width + (int)((PART_FooterColumn.ActualWidth
+                                                    + PART_RightPaddingColumn.ActualWidth
+                                                    + PART_RootGrid.Padding.Right)
+                                                    * scaleAdjustment);
+            rect4.Width = (int)(PART_RightPaddingColumn.ActualWidth * scaleAdjustment);
 
+            Windows.Graphics.RectInt32[] dragRects = new[] { rect1, rect2, rect3, rect4 };
             Window.AppWindow.TitleBar.SetDragRectangles(dragRects);
         }
     }

------------- dev/Components/Controls/Labs/TitleBar/TitleBar.xaml -------------
index 61e01c5..983dad2 100644
@@ -18,7 +18,7 @@
                 <ControlTemplate TargetType="local:TitleBar">
                     <Grid x:Name="PART_RootGrid"
                           Height="{TemplateBinding MinHeight}"
-                          Padding="4,0,4,0"
+                          Padding="4,0,0,0"
                           VerticalAlignment="Stretch"
                           Background="{TemplateBinding Background}">
                         <Grid.ColumnDefinitions>

---------------------- dev/Components/Themes/Generic.xaml ----------------------
index 877fb1e..ae49b15 100644
@@ -2090,7 +2090,7 @@ Themes\Styles\TextBlock.xaml
     <win:Setter Property="Template">
       <win:Setter.Value>
         <win:ControlTemplate TargetType="local:TitleBar">
-          <win:Grid x:Name="PART_RootGrid" Height="{TemplateBinding MinHeight}" Padding="4,0,4,0" VerticalAlignment="Stretch" Background="{TemplateBinding Background}">
+          <win:Grid x:Name="PART_RootGrid" Height="{TemplateBinding MinHeight}" Padding="4,0,0,0" VerticalAlignment="Stretch" Background="{TemplateBinding Background}">
             <win:Grid.ColumnDefinitions>
               <win:ColumnDefinition x:Name="PART_LeftPaddingColumn" Width="0" />
               <win:ColumnDefinition x:Name="PART_ButtonsHolderColumn" Width="Auto" />

i found a bug with your titlebar

image

this is my code

when i select the light the icon is black
instead is white ,but when i select light to use system setting,the icon color is not change,
but select from dark to use system setting the codition is normal

2023-10-16.165643.mp4

Cannot add package into class library project

Step 1 : create class library for winui project (.net 6 or 8) via VS2022 project template

θž’εΉ•ζ“·ε–η•«ι’ 2023-12-28 141202

Step 2 : update all nuget packages
Step 3 : add WinUICommunity.Core into this project

θž’εΉ•ζ“·ε–η•«ι’ 2023-12-28 141254

Step 4 : build and compile failed

θž’εΉ•ζ“·ε–η•«ι’ 2023-12-28 141321

if we change the step1 , create a winui app project instead of class library for winui project, it work well ~

Reg... Dark Theme.

Switching to dark theme, displays in light gray than black... Have i missed something... the version im using is .net7 and the template..

TIA

[Bug] NavigationService -Footer navigation doesn't work

It is not possible to navigate to a FooterNavigationViewItem.
The problem is that JsonNavigationViewService only returns the MenuItems,
the FooterMenuItems are not returned.
IList<object>? MenuItems => _navigationView?.MenuItems;
This means that only the MenuItems are configured in ConfigPages.

    private void ConfigPages()
    {
        _pageService.GetPages(MenuItems);

It would be conceivable to also integrate the FooterItems into ConfigPages.
Either the IList<object>? MenuItems also contains the FooterItems,
or an additional IList<object>? FooterMenuItems which is then processed by the ConfigPages.

[SUGGESTION] Rename services and helpers.

I've been using the official WinUI templates to set up navigation + your winui core features. However, I've been running into some issues with namespace references, especially when it comes to navigation elements like INavigationService, INavigationAware, PageService, etc.

I'm aware that these issues can be resolved with proper usings and External Aliases, but it seems a bit cumbersome.

Growl Global throwing error on Win10 machines.

On Win11 machine, i have no issue running this code:

  Growl.AskGlobal("Do you want to install new version?", (s, e) =>
  {
      Task.WaitAll(Task.Run(async () =>
      {
          await updateService.DownloadRelease(assetId);
      }));
      updateService.InstallLatestRelease();
      App.Current.Exit();
      return true;
  });

but i tried it on two different win10 machines and i receive this error:
Value does not fall within the expected range. with the stack:

   at WinUICommunity.NativeMethods.DwmSetWindowAttribute(IntPtr hwnd, DWMWINDOWATTRIBUTE dwAttribute, UInt32& pvAttribute, UInt32 cbAttribute)
   at WinUICommunity.WindowHelper.SetWindowCornerRadius(IntPtr hwnd, DWM_WINDOW_CORNER_PREFERENCE cornerPreference)
   at WinUICommunity.WindowHelper.SetWindowCornerRadius(Window window, DWM_WINDOW_CORNER_PREFERENCE cornerPreference)
   at WinUICommunity.GrowlWindow.Init()
   at WinUICommunity.Growl.InitGrowlGlobal(GrowlInfo growlInfo, Boolean isForceSeverity, InfoBarSeverity forceSeverity)
   at WinUICommunity.Growl.AskGlobal(String title, Func`3 actionBeforeClose)

i also noticed that using regular Growl (not global) doesn't show anything.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.