左右粗边框

Thick border on the right and on the left

我的 RibbonWindow 桌面应用程序在 和 Windows 10 的两侧显示 粗黑边框 。您可以通过一个显示 RibbonWindow 的简单 WPF 应用程序重现这一点。 Windows 8.x.

显示边框 not

有谁知道,如何去除边框?

有人在 msdn, and the answer 'it's a known issue'. But following the provided link 上问过类似的问题,我找不到任何具体的问题。

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

编辑:如果 window 未激活,边框颜色为黑色。如果 window 处于活动状态,边框的颜色来自自定义的 windows 强调色。

考虑使用 WindowChrome with GlassFrameThickness = GlassFrameCompleteThickness

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

有关在使用 WindowChrome 时如何管理内容布局的示例,请参阅 this 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>

生成的 RibbonWindow 看起来像这样: