【问题标题】:MahApps.Metro 0.13.1: Show window commands without display the titlebarMahApps.Metro 0.13.1:显示窗口命令而不显示标题栏
【发布时间】:2014-04-16 03:27:23
【问题描述】:

我正在使用 MahApps.Metro 0.12.1 在 WPF 中开发应用程序。在这个应用程序中,我不显示标题栏,保持可见的最小化、最大化和关闭命令。下面我展示代码:

<controls:MetroWindow xmlns:views="clr-namespace:View.Views"  
    xmlns:titleBar="clr-namespace:View.Views.TitleBar"  
    x:Class="View.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    GlowBrush="{DynamicResource AccentColorBrush}"
    ShowWindowCommandsOnTop="False" 
    ShowTitleBar="False"
    Title="MainWindow" Height="400" Width="600"
    AllowsTransparency="False">
<Grid>
    ...
</Grid>

当我升级到 MathApps.Metro 的 0.13.1 版本时出现问题,这些命令没有显示,迫使我重新建立标题栏以再次显示命令ShowTitleBar="True" 这就是我不想:显示标题栏

我正在查看 MathApps.Metro 0.13.1 的发行说明,并报告说对标题栏的部分进行了更改,但没有提供更多详细信息。

我的问题是:有没有一种简单的方法来显示最小化、最大化和关闭命令而不显示标题栏?做这个的最好方式是什么?

谢谢

【问题讨论】:

    标签: wpf mahapps.metro


    【解决方案1】:

    您可以像这样将窗口按钮直接放在主窗口中

    <Grid>
      <!-- the window button commands -->
      <Controls:WindowButtonCommands Panel.ZIndex="1"
                                     HorizontalAlignment="Right"
                                     VerticalAlignment="Top"
                                     Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
    
        ...
    </Grid>
    

    希望对你有帮助

    【讨论】:

      【解决方案2】:

      有没有一种简单的方法来显示最小化、最大化和关闭命令而不显示标题栏?最好的方法是什么?

      其实不是很简单,但是有可能。基本上,您需要创建自己的 Style 模板并覆盖 ContentPresenter 以便您的窗口这样做。

      你可以看看this问题。

      除此之外,this 帖子将指导您完成设计自己的标题栏的过程。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多