我的浏览器又出现了另一个问题。我做了一个自定义的标题栏,标签进入标题栏,以创造一个更身临其境的体验。但所有的“身临其境的体验”正在被这个似乎无法修复的错误破坏。我试图做的是改变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="" 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>
如果你真的需要c#代码,那么就注解一下。因为我只有两行c#代码与标题栏相关。
1条答案
按热度按时间piztneat1#
在我的示例中,我可以通过将
WindowCaptionsBackground
和WindowCaptionsBackgroundDisabled
属性设置为Transparent
,将title栏设置为xaml中定义的颜色,如下所示:App.xaml
有关自定标题栏的更多信息:https://learn.microsoft.com/en-us/windows/apps/develop/title-bar?tabs=winui3