2

理想情况下,它应该看起来像 GlassWire 应用程序所具有的东西(左上角):

https://www.glasswire.com/images/feature_image_remote_monitoring.png

它的行为就像一个应用程序图标系统菜单,但更明显和可定制。

我遇到的具体问题是:

1)我如何轻松添加标题栏友好的汉堡菜单按钮(理想情况下仅适用于XAML),例如通过mahApps:MetroWindow.LeftWindowCommands

2)我如何自定义它看起来就像 GlassWire 的菜单按钮(顶部对齐零顶部边距细矩形)?我尝试使用对齐和高度,但它不起作用 - 顶部总是有一个间隙。

这是我到目前为止所拥有的(应用程序图标旁边的汉堡按钮):

汉堡按钮但没有菜单

<mahApps:MetroWindow.LeftWindowCommands>
    <mahApps:WindowCommands ShowSeparators="False">
        <Button>
            <Button.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Menu Item 1"/>
                    <MenuItem Header="Menu Item 2"/>
                    <MenuItem Header="Menu Item 3"/>
                </ContextMenu>
            </Button.ContextMenu>
            <Rectangle Width="14" Height="14" Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
                <Rectangle.OpacityMask>
                    <VisualBrush Stretch="Fill" Visual="{StaticResource appbar_lines_horizontal_4}" />
                </Rectangle.OpacityMask>
            </Rectangle>
        </Button>
    </mahApps:WindowCommands>
</mahApps:MetroWindow.LeftWindowCommands>

不幸的是,上下文菜单并不理想,因为它的行为需要一些 C# 代码才能使其正确。

4

0 回答 0