右侧和左侧的粗边框

时间:2015-11-22 16:24:50

标签: c# wpf windows-10 ribbon

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

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

enter image description here

有些人在msdn上提出了类似的问题,答案是'这是一个已知的问题'。但是按照提供的link我找不到任何具体的内容。

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

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

1 个答案:

答案 0 :(得分:2)

考虑将WindowChromeGlassFrameThickness = GlassFrameCompleteThickness一起使用。

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

有关如何在使用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看起来像这样:

enter image description here

相关问题