2015-11-22 167 views
5

我的RibbonWindow桌面应用程序在Windows 10的两侧上显示一个厚的黑色边框。您可以通过显示RibbonWindow的简单WPF应用程序来重现此情况。边框是不是显示在Windows 8.x右边和左边的厚边框

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

enter image description here

有些人问上msdn类似的问题,而答案“这是一个已知的问题”。但遵循提供的link我找不到任何具体的。

那么有人能帮助我吗?

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

+0

根据您所提供它看起来的链接像它只是,'已知问题'。另一张海报称,不使用RibbonWindow,因为它非常过时。在查看了RibbonWindow的一些问题之后,看起来微软已经关闭了很多这些问题,并将它们设置为“无法修复”,尽管它们是相对严重的问题。这可能是RibbonWindow正在被弃用的方式。 – Danielle

+0

至少RibbonWindow尚未弃用。在链接之后,没有描述“边界错误”。只有:*当窗口处于最大化模式时,窗口内容(客户端区域)被裁剪。 *窗口边框太薄。 * QuickAccessToolbar的顶部没有足够的“边距”。 *窗口标题模糊,顶部没有足够的“边距”。 – gReX

+0

https://connect.microsoft.com/VisualStudio/Feedback/Details/1263145 – gReX

回答

1

考虑使用WindowChromeGlassFrameThickness = GlassFrameCompleteThickness

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

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

这是一个完整的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

+0

非常好。它适用于我的示例项目:-)。而是将Boarder设置为小麦我将它绑定到{DynamicResource {x:Static SystemColors.ActiveBorderBrush}}。检查对我的风格的影响。 – gReX