【问题标题】:Commandbar in Windows Phone 8.1Windows Phone 8.1 中的命令栏
【发布时间】:2015-01-19 05:47:04
【问题描述】:

如何在 windows phone 8.1 (winprt) 应用程序中使用 C# 制作辅助命令?

//WINRT:
CommandBar CommandBarObject = new CommandBar();
AppBarButton FirstBtn = new AppBarButton() { Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Assets/first.png") } };
FirstBtn.Label = "First";
FirstBtn.Click += FirstBtn_Click;
FirstBtn.IsEnabled = true;

CommandBarObject.PrimaryCommands.Add(FirstBtn);
CommandBarObject.SecondaryCommands.Add(secondaryCommand);

现在如何制作这个secondaryCommand

【问题讨论】:

    标签: c# xaml windows-runtime windows-phone-8.1 commandbar


    【解决方案1】:

    放在那里AppBarButton

     CommandBar CommandBarObject = new CommandBar();
     AppBarButton FirstBtn = new AppBarButton() { Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Assets/first.png") } };
     FirstBtn.Label = "First";
     FirstBtn.Click += FirstBtn_Click;
     FirstBtn.IsEnabled = true;
    
     AppBarButton secondaryCommand = new AppBarButton() { Label = "Second", IsEnabled = true } };
     secondaryCommand.Click += FirstBtn_Click;
    
     CommandBarObject.PrimaryCommands.Add(FirstBtn);
     CommandBarObject.SecondaryCommands.Add(secondaryCommand);
    

    【讨论】:

    • 用代码试过了,还加了:CommandBarObject = this.BottomAppBar as CommandBar;但应用栏未显示在页面上。可能缺少什么?
    • @AtifShabeer 您是否设置了 Page 的 BottomAppBar? this.BottomAppBar = CommandBarObject;
    • 非常感谢,成功了,请问如何修改secondarycommand文本的fontSize?
    • @AtifShabeer AFAIK 您无法更改辅助命令的字体大小。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多