为了账号安全,请及时绑定邮箱和手机立即绑定

XAML UWP AppBar 没有响应

XAML UWP AppBar 没有响应

C#
慕神8447489 2022-11-13 14:24:44
我的 UWP 应用程序出现奇怪的行为。我的页面顶部有一个带有三个按钮的 AppBar。当我通过 NavView 导航到我的页面时,AppBar 没有响应,按钮和菜单(三个点)都没有响应,也没有“鼠标悬停”。当我再次导航到该页面时,它工作正常。据我所知,当我删除代码中的“isOpen”属性时,它似乎可以正常工作。一旦我设置了属性(在 C# 或 XAML 代码中),它在第一次导航时就没有响应<AppBar x:Name="AppBar" IsSticky="True" Margin="0,0,0,0"  IsOpen="True" >  <StackPanel Orientation="Horizontal">    <AppBarButton Label="Reset" Icon="AllApps" Click="ButtonResetGrid" />    <AppBarButton Label="Export" Icon="AllApps" Click="ButtonExport" />    <AppBarButton Label="Refresh" Icon="AllApps" Click="ButtonRefreshCode" />  </StackPanel></AppBar>这是第一次导航到页面时不工作:第二次导航后(您可以看到鼠标悬停):预期行为也许有人有想法或好的提示。
查看完整描述

2 回答

?
千巷猫影

TA贡献1829条经验 获得超7个赞

官方文档中有备注,只有在升级使用 AppBar 的 Universal Windows 8 应用时才应该使用 AppBar,并且需要尽量减少改动。对于 Windows 10 中的新应用,我们建议改用该CommandBar控件。请尝试CommandBar如下使用。


<CommandBar>

    <AppBarButton Label="Reset" Icon="AllApps" Click="ButtonResetGrid" />

    <AppBarButton Label="Export" Icon="AllApps" Click="ButtonExport" />

    <AppBarButton Label="Refresh" Icon="AllApps" Click="ButtonRefreshCode" />

    <CommandBar.SecondaryCommands>

        <AppBarButton Icon="Like" Label="Like" />

        <AppBarButton Icon="Dislike" Label="Dislike" />

    </CommandBar.SecondaryCommands>


    <CommandBar.Content>

        <TextBlock Text="Now playing..." Margin="12,14"/>

    </CommandBar.Content>

</CommandBar>

更新


如果你想让所有 AppBarButtons conllection 离开,你需要像链接一样自定义 CommandBar 样式。


查看完整回答
反对 回复 2022-11-13
?
慕森卡

TA贡献1806条经验 获得超8个赞

你能试试吗,因为它可能会起作用:


 <Page.TopAppBar>

        <AppBar x:Name="AppBar" IsSticky="True" Margin="0,0,0,0"  IsOpen="True">

                <StackPanel Orientation="Horizontal">

                    <Button Content="Reset" Width="140" Height="80" Click="ButtonResetGrid_Click"/>

                    <Button Content="Export" Width="140" Height="80" Icon="AllApps" Click="ButtonExport_Click"/>

                    <Button Content="Refresh" Width="140" Height="80" Icon="AllApps" Click="ButtonRefreshCode_Click"/>

                </StackPanel>


        </AppBar>

    </Page.TopAppBar>


查看完整回答
反对 回复 2022-11-13
  • 2 回答
  • 0 关注
  • 123 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号