【问题标题】:How do I hide the default toolbar button (three dots) in Xamarin.Forms UWP如何在 Xamarin.Forms UWP 中隐藏默认工具栏按钮(三个点)
【发布时间】:2019-04-08 07:19:38
【问题描述】:

我有一个 Xamarin.Forms UWP 应用,其 <ContentPage.ToolbarItems> 定义了两个工具栏项。 在 UWP 中,此工具栏呈现但显示一个带有 3 个点的额外(或默认)按钮,该按钮展开但不包含任何按钮。我想删除这个额外的按钮。

我找到了一些关于这个问题的参考资料,但它们对我不起作用:

【问题讨论】:

    标签: c# xamarin uwp toolbar


    【解决方案1】:

    根据您在帖子中提到的链接中的答案,您是否尝试将以下代码放入您的 UWP 项目的 App.Xaml 中:

    <Application.Resources>
       <x:Double x:Key="AppBarExpandButtonThemeWidth">0</x:Double>
    </Application.Resources>
    

    【讨论】:

    • 我试过了,但也许我把它放在了错误的 App.Xaml 中。有了你的提示,它奏效了。
    【解决方案2】:

    由于 Windows 10 周年版(因此您的项目的最低版本为 14393,目标版本为 14393 或更高版本),CommandBar 上有一个属性可用于切换 3 个点/更多按钮的可见性。

    调用 OverflowButtonVisibilty,文档在这里: https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.commandbar.overflowbuttonvisibility

    你可以这样设置

    <CommandBar OverflowButtonVisibility="Collapsed"></CommandBar>
    

    【讨论】:

    • 这个答案不适用于我的场景,因为工具栏项是在我的共享 xamarin 项目中定义的,而不是在我的 uwp 项目中
    • 是的,但您仍然可以将该属性设置为 UWP 项目 app.xaml 中的样式,以便在那里触发
    • @Depechie :您能否在答案中添加在app.xaml 中设置属性的行?
    • @Christian 不确定您在问什么?您想要一个将其设置为您的意思的样式的示例吗?
    • @Depechie Dishant's answer 的风格。
    猜你喜欢
    • 1970-01-01
    • 2013-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多