自定义标题栏在Winui 3中显示白色3

发布于 2025-02-08 19:09:37 字数 3778 浏览 3 评论 0原文

我正在浏览浏览器中的另一个问题。我做了一个自定义标题栏,标签进入标题栏,以创造更身临其境的体验。但是,所有这些看似不可修复的虫子破坏了所有这些“沉浸式体验”。我试图做的是更改CustomDragregion元素的背景。

看标题栏。那真令人恶心。有人帮我。请

注意代码:

<Window
x:Class="Microsoft_Edge_WebView2_Runtime_Application.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft_Edge_WebView2_Runtime_Application"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">
<Grid BorderBrush="Transparent" x:Name="Browser" Margin="0,0,0,0" Background="{ThemeResource SystemControlBackgroundAccentRevealBorderBrush}">
    <TabView Margin="0, 0, 0, 0" x:Name="Tabv" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AddTabButtonClick="TabView_AddTabButtonClick" TabCloseRequested="TabView_TabCloseRequested">
        <TabViewItem FontFamily="Gellix" x:Name="HomeTab" Header="Home" IsClosable="False">
            <TabViewItem.IconSource>
                <SymbolIconSource Symbol="Document" />
            </TabViewItem.IconSource>

            <Grid x:Name="TabContent" Margin="0,0,0,0" Background="#282828">
                <WebView2 x:Name="WebView" Source="https://google.com" Margin="0,52,0,0"/>
                <Grid Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Width="666">
                    <TextBox KeyDown="AddressBar_KeyDown" FontFamily="Gellix" x:Name="AddressBar" HorizontalAlignment="Center" TextWrapping="NoWrap" Text="" VerticalAlignment="Center" Width="576" PlaceholderText="Search or type a URL here..." TextAlignment="Center" />
                    <Button Height="32" Width="40" x:Name="Home" Click="Button_Click_1">
                        <FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xE80F;" Margin="-2,-1,-2,-1"/>
                    </Button>
                    <Button Height="32" Width="40" x:Name="Go" Margin="626,0,0,0" Click="Button_Click">
                        <FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xE751;" Margin="-2,-1,-2,-1"/>
                    </Button>
                </Grid>
                <Button x:Name="Refresh" Margin="0,10,10,0" VerticalAlignment="Top" Height="32" Width="40" FontFamily="Segoe UI Symbol" Click="Button_Click" HorizontalAlignment="Right">
                    <FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xe72c;" Margin="-2,-1,-2,-1"/>
                </Button>
                <Button x:Name="Backward" Margin="10,10,0,0" VerticalAlignment="Top" Height="32" Width="40" FontFamily="Segoe UI Symbol" Click="Backward_Click">
                    <FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xf0d3;" Margin="-2,-1,-2,-1"/>
                </Button>
                <Button x:Name="Forward" Margin="53,10,0,0" VerticalAlignment="Top" Height="32" Width="40" FontFamily="Segoe UI Symbol" Click="Forward_Click">
                    <FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xF0D2;" Margin="-2,-1,-2,-1"/>
                </Button>
            </Grid>
        </TabViewItem>
        <TabView.TabStripFooter>
            <Grid Margin="0,0,0,0"  x:Name="CustomDragRegion" Background="Transparent"/>
        </TabView.TabStripFooter>
    </TabView>


</Grid>

如果您真的需要C#代码,请注释。因为我只有两行C#与标题栏有关。

I'm back with another problem in my browser that I'm working on. I made a custom title bar where the Tabs come into the title bar to create a more immersive experience. but all that "Immersive experience" is being ruined by this seemingly unfixable bug. what ive tried to do is change the background of the CustomDragRegion Element.
My App

look at the title bar. its disgusting. someone help me. plss

heres the code:

<Window
x:Class="Microsoft_Edge_WebView2_Runtime_Application.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft_Edge_WebView2_Runtime_Application"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">
<Grid BorderBrush="Transparent" x:Name="Browser" Margin="0,0,0,0" Background="{ThemeResource SystemControlBackgroundAccentRevealBorderBrush}">
    <TabView Margin="0, 0, 0, 0" x:Name="Tabv" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AddTabButtonClick="TabView_AddTabButtonClick" TabCloseRequested="TabView_TabCloseRequested">
        <TabViewItem FontFamily="Gellix" x:Name="HomeTab" Header="Home" IsClosable="False">
            <TabViewItem.IconSource>
                <SymbolIconSource Symbol="Document" />
            </TabViewItem.IconSource>

            <Grid x:Name="TabContent" Margin="0,0,0,0" Background="#282828">
                <WebView2 x:Name="WebView" Source="https://google.com" Margin="0,52,0,0"/>
                <Grid Margin="0,10,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Width="666">
                    <TextBox KeyDown="AddressBar_KeyDown" FontFamily="Gellix" x:Name="AddressBar" HorizontalAlignment="Center" TextWrapping="NoWrap" Text="" VerticalAlignment="Center" Width="576" PlaceholderText="Search or type a URL here..." TextAlignment="Center" />
                    <Button Height="32" Width="40" x:Name="Home" Click="Button_Click_1">
                        <FontIcon FontFamily="Segoe Fluent Icons" Glyph="" Margin="-2,-1,-2,-1"/>
                    </Button>
                    <Button Height="32" Width="40" x:Name="Go" Margin="626,0,0,0" Click="Button_Click">
                        <FontIcon FontFamily="Segoe Fluent Icons" Glyph="" Margin="-2,-1,-2,-1"/>
                    </Button>
                </Grid>
                <Button x:Name="Refresh" Margin="0,10,10,0" VerticalAlignment="Top" Height="32" Width="40" FontFamily="Segoe UI Symbol" Click="Button_Click" HorizontalAlignment="Right">
                    <FontIcon FontFamily="Segoe Fluent Icons" Glyph="" Margin="-2,-1,-2,-1"/>
                </Button>
                <Button x:Name="Backward" Margin="10,10,0,0" VerticalAlignment="Top" Height="32" Width="40" FontFamily="Segoe UI Symbol" Click="Backward_Click">
                    <FontIcon FontFamily="Segoe Fluent Icons" Glyph="" Margin="-2,-1,-2,-1"/>
                </Button>
                <Button x:Name="Forward" Margin="53,10,0,0" VerticalAlignment="Top" Height="32" Width="40" FontFamily="Segoe UI Symbol" Click="Forward_Click">
                    <FontIcon FontFamily="Segoe Fluent Icons" Glyph="" Margin="-2,-1,-2,-1"/>
                </Button>
            </Grid>
        </TabViewItem>
        <TabView.TabStripFooter>
            <Grid Margin="0,0,0,0"  x:Name="CustomDragRegion" Background="Transparent"/>
        </TabView.TabStripFooter>
    </TabView>


</Grid>

if you really need c# code then just comment. cuz I have only two lines of c# related to the title bar.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

£冰雨忧蓝° 2025-02-15 19:09:37

就我而言,我能够通过设置windercaptionsbackgroundWindowsCaptionsBackgroundDisabled属性属性透明作为透明,将其设置为XAML定义的颜色的titter bar,为这样的:

app.xaml

<Application
    ...
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
                <!-- Other merged dictionaries here -->
            </ResourceDictionary.MergedDictionaries>
            <!-- Other app resources here -->
            <SolidColorBrush x:Key="WindowCaptionBackground">Transparent</SolidColorBrush>
            <SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">Transparent</SolidColorBrush>
        </ResourceDictionary>
    </Application.Resources>
    
</Application>

有关自定义tittle bar的更多信息: https://learn.microsoft.com/en-us/windows/papps/develop/title-bar?tabs=winui3

In my case, I was able set the tittle bar to the color defined in the xaml by setting the WindowCaptionsBackground and WindowCaptionsBackgroundDisabled properties to Transparent, as such:

App.xaml

<Application
    ...
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
                <!-- Other merged dictionaries here -->
            </ResourceDictionary.MergedDictionaries>
            <!-- Other app resources here -->
            <SolidColorBrush x:Key="WindowCaptionBackground">Transparent</SolidColorBrush>
            <SolidColorBrush x:Key="WindowCaptionBackgroundDisabled">Transparent</SolidColorBrush>
        </ResourceDictionary>
    </Application.Resources>
    
</Application>

More info on customizing the tittle bar: https://learn.microsoft.com/en-us/windows/apps/develop/title-bar?tabs=winui3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文