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

Extending to titlebar is not working as expected (WinAppSDK 1.0.1) #6858

Closed
1 of 2 tasks
harvinders opened this issue Mar 20, 2022 · 6 comments
Closed
1 of 2 tasks

Extending to titlebar is not working as expected (WinAppSDK 1.0.1) #6858

harvinders opened this issue Mar 20, 2022 · 6 comments
Labels
area-TitleBar Issues related to custom window title bars. duplicate This issue or pull request already exists product-winui3 WinUI 3 issues team-Reach Issue for the Reach team

Comments

@harvinders
Copy link

Describe the bug

After following the titlebar customisation for a WinUI 3, WinAppSDK 1.0.1 app, following observations are made

[1] Setting the title bar with a Margin=0,0,120,0

  • A gray overlay is displayed over the titlebar, except at the either end of the titlebar, both left and right. On Right it is expected as margin of 120 is given but why left.

  • System control buttons (min, max, close) don't function either
    image

  • Changing the Margin=0,0,12,0 also changes the margin on both ends, not just right.
    image

[2] Setting the title bar with a Margin=0,0,0,0

  • A gray overlay is now displayed over whole of titlebar.
  • However, system controls (min, max, close) now work
    image

Steps to reproduce the bug

<Window
    x:Class="Raya.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Raya"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid Grid.RowDefinitions="48,*" >

        <Grid x:Name="AppTitleBar" Margin="0,0,120,0" Background="Pink">
            <Image Source="Assets/StoreLogo.png"
                   HorizontalAlignment="Left" 
                   Width="16" Height="16" 
                   Margin="8,0"/>
            <TextBlock x:Name="AppTitleTextBlock" Text="App title ewr iueyr iuwe riu qwiuy qiwueyr iquwy iuwqy iureyqwiu"
                       TextWrapping="NoWrap"
                       Style="{StaticResource CaptionTextBlockStyle}" 
                       VerticalAlignment="Center"
                       Margin="28,0,0,0"/>
        </Grid>
        <ContentControl Grid.Row="1"   x:Name="MainContent" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>
    </Grid>
</Window>
    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
            ExtendsContentIntoTitleBar = true;
            SetTitleBar(AppTitleBar);
        }

        public object BodyContent
        {
            get => MainContent.Content;
            set => MainContent.Content = value;
        }
    }

Expected behavior

  1. Gray overlay should not be displayed
  2. System controls should work as per the documentaion

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.0

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 10 (20H2): Build 19042

Additional context

I am not using the single project packaged solution, but updated my earlier project with two csproj to 1.0.1 SDK.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Mar 20, 2022
@ojhad ojhad added team-Reach Issue for the Reach team area-TitleBar Issues related to custom window title bars. labels Mar 21, 2022
@ojhad
Copy link
Contributor

ojhad commented Mar 21, 2022

@bpulliam @pratikone please take a look

@ojhad ojhad added the product-winui3 WinUI 3 issues label Mar 21, 2022
@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Mar 24, 2022
@pratikone
Copy link
Contributor

refer response in #6895 1084868757. Margin is the issue. It was a workaround earlier for a issue which has now been fixed. working with docs team to get the sample code updated.

@pratikone pratikone added the duplicate This issue or pull request already exists label Mar 31, 2022
@harvinders
Copy link
Author

@pratikone What about the smoke layer? Can't we get rid of that? The whole idea of extending the content to the titlebar is to blend the titlebar and the content and have the same background/material

@lakienvinh
Copy link

In the App.xaml file you can set the "smoke layer" to transparent:

<SolidColorBrush x:Key="WindowCaptionBackground" Color="Transparent"/> <SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Transparent"/>

More codes:

<SolidColorBrush x:Key="WindowCaptionBackground" Color="Transparent"/> <SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="Transparent"/> </ResourceDictionary> </Application.Resources>

@harvinders
Copy link
Author

@lakienvinh, this works for me, however, I noticed another issue, if I switch to the dark mode (programatically setting RequestedTheme) even after extending the content into titlebar I still see a light titlebar in light and dark content. @pratikone any idea what is going on there?

@pratikone
Copy link
Contributor

yes. it puzzled me too. TBH, i don't know how that came to be. good news is i made a series of new changes for separate reasons and this issue went away. it will come in a future . feel free to open this issue if it doesn't get fixed in next 1-2 releases.

symonxdd added a commit to symonxdd/epic-games-account-switcher that referenced this issue Mar 11, 2023
To enable that familiar WinUI 3 titlebar, these 3 code snippets need to be added to the project:

- `MainWindow.xaml.cs`:
Check this method: `EnableModernTitlebar()`

- `MainWindow.xaml`:
Check for the Border control with name `appTitleBar`

- `App.xaml`:
This part is needed to achieve a true black color in the titlebar... Source found [here](microsoft/microsoft-ui-xaml#6858 (comment))
```
<SolidColorBrush x:Key="WindowCaptionBackground" Color="#121212"/>
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled" Color="#121212"/>
```

Also, running the app in Unpackaged mode, is only possible when this property is set to true in the project config file (`EpicGamesAccountSwitcher.csproj`). Put it in the main `<PropertyGroup>`:
`<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TitleBar Issues related to custom window title bars. duplicate This issue or pull request already exists product-winui3 WinUI 3 issues team-Reach Issue for the Reach team
Projects
None yet
Development

No branches or pull requests

5 participants