5
A
回答
1
考虑使用WindowChrome和GlassFrameThickness = 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会是这个样子:
+0
非常好。它适用于我的示例项目:-)。而是将Boarder设置为小麦我将它绑定到{DynamicResource {x:Static SystemColors.ActiveBorderBrush}}。检查对我的风格的影响。 – gReX
相关问题
- 1. 右边和左边的UIButton边框
- 2. 左边,上边,下边和右边的颜色渐变边框
- 3. 与左边和右边
- 4. VIM中心文字屏幕,左边和右边无效边框
- 5. 左边是浮动右边
- 6. 修复CSS边框右和左边框的问题
- 7. 平等左边框和右边框的高度在CSS
- 8. 对齐左边中间和右边
- 9. Wpf Dock Dock左边和Dock右边
- 10. Css边框适合左右
- 11. C#Excel左右边框
- 12. 使用css向右边框和左边框倾斜
- 13. 左边框和右边框不显示在浏览器
- 14. LinearLayout:左边的TextViews,右边的ImageView大
- 15. 在JS中旋转身体,左边变为左边,右边变为左边
- 16. 填充右侧和左侧边框
- 17. 拆下左侧和右侧边框
- 18. 需要一个正则表达式来替换左边的右边和右边的左边
- 19. 删除边界上最左边和最右边
- 20. 没有底部边框的全高左右边框
- 21. 可在Android中使用左侧或右侧边距绘制边框的边框
- 22. CSS Float左边然后右边
- 23. 浮动div左边,其他div右边
- 24. 左边2个div 1右边
- 25. 复选框与codeigniter和边框厚度
- 26. 我可以同时设置边界左边界和右边界边界吗?
- 27. 悬停框的动画边框(边框左侧,边框顶部)
- 28. 边框厚度过渡
- 29. 动画UIButton边框厚度
- 30. css3左边的锯齿边不是右边的
根据您所提供它看起来的链接像它只是,'已知问题'。另一张海报称,不使用RibbonWindow,因为它非常过时。在查看了RibbonWindow的一些问题之后,看起来微软已经关闭了很多这些问题,并将它们设置为“无法修复”,尽管它们是相对严重的问题。这可能是RibbonWindow正在被弃用的方式。 – Danielle
至少RibbonWindow尚未弃用。在链接之后,没有描述“边界错误”。只有:*当窗口处于最大化模式时,窗口内容(客户端区域)被裁剪。 *窗口边框太薄。 * QuickAccessToolbar的顶部没有足够的“边距”。 *窗口标题模糊,顶部没有足够的“边距”。 – gReX
https://connect.microsoft.com/VisualStudio/Feedback/Details/1263145 – gReX