右侧和左侧的粗边框

gRe*_*ReX 5 c# wpf ribbon windows-10

我的RibbonWindow桌面应用程序在Windows 10中的两侧都显示黑色粗边框.您可以通过显示RibbonWindow的简单WPF应用程序重现此问题.Windows 8.x显示边框.

有人知道,如何删除边框?

在此输入图像描述

有人在msdn上问了一个类似的问题,答案是'这是一个已知的问题'.但是根据提供的链接,我找不到任何具体的.

所以有人可以帮我解决这个问题吗?

编辑:如果窗口未激活,则边框的颜色为黑色.如果窗口处于活动状态,则边框将从自定义窗口强调颜色中获取颜色.

Vat*_*san 2

考虑将WindowChromeGlassFrameThickness = GlassFrameCompleteThickness结合使用。

这不是一个理想的解决方案 - 您必须仔细为窗口标题以及最大化、最小化和关闭按钮腾出空间。也就是说,它确实消除了您正在处理的边界问题。

有关如何在使用 WindowChrome 时管理内容布局的示例,请参阅SO 答案。

下面是一个完整的 XAML,应该也会有所帮助:

<RibbonWindow x:Class="RibbonTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:RibbonTest"
              xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"
        mc:Ignorable="d"
        Title="RibbonWindow" Height="350" Width="525">
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="{x:Static shell:WindowChrome.GlassFrameCompleteThickness}"/>
    </WindowChrome.WindowChrome>
    <Window.Template>
        <ControlTemplate>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="1*"/>
                </Grid.RowDefinitions>

                <!-- Opacity of < 1.0 helps show the minimize, maximize and close buttons -->
                <Border Grid.Row="0" Background="Wheat" Opacity="0.8">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="30" />
                            <ColumnDefinition Width="1*"/>
                        </Grid.ColumnDefinitions>


                        <!-- Window Title - Center Aligned -->
                        <TextBlock 
                            Grid.Column="1"
                            TextAlignment="Center" 
                            VerticalAlignment="Center"
                            Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}}" />

                    </Grid>
                </Border>

                <!-- This is the Window's main content area -->
                <!-- Top margin 44 = WindowChrome ResizeBorderThickness (4) + CaptionHeight(40) -->
                <!-- Bottom margin 1 is somewhat arbitrary -->
                <Border Grid.Row="1" Background="White" Opacity="0.5">
                    <ContentPresenter Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"/>
                </Border>
            </Grid>
        </ControlTemplate>
    </Window.Template>
    <Grid>
        <Border Background="Cyan" BorderBrush="BlanchedAlmond" BorderThickness="5">
            <Label FontSize="80" HorizontalAlignment="Center" VerticalAlignment="Center">Hello World</Label>
        </Border>
    </Grid>
</RibbonWindow>
Run Code Online (Sandbox Code Playgroud)

生成的 RibbonWindow 看起来像这样:

在此输入图像描述