【问题标题】:How to customize the Device charm bar using C#/XAML in windows 8?如何在 Windows 8 中使用 C#/XAML 自定义设备魅力栏?
【发布时间】:2016-11-04 22:48:45
【问题描述】:

我有一个需求,需要在 windows 8 中自定义设备魅力栏?

我需要在设备超级按钮栏中添加一个按钮或任何其他控件。

  1. 有可能吗?
  2. 如果是,我们如何定制它?

提前致谢。

【问题讨论】:

    标签: printing windows-8 charms-bar


    【解决方案1】:

    您当然可以像这样向 Device 的超级按钮栏添加命令: 我假设您想添加到设置超级按钮栏。

    创建一个类示例 AppSettings

    public AppSetting()
    {
        SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
        SizeChanged += AppSettingSizeChanged;
    }
    
    
    private void OnCommandsRequested(SettingsPane settingsPane, SettingsPaneCommandsRequestedEventArgs eventArgs)
    {
        eventArgs.Request.ApplicationCommands.Clear();
    
        UICommandInvokedHandler handler = new UICommandInvokedHandler(OnSettingsCommand);
    
        // Some command
        SettingsCommand someCommand = new SettingsCommand("uniqueID", "NameofLabel", handler);
                eventArgs.Request.ApplicationCommands.Add(someCommand);
    }
    
    
    
    private void OnSettingsCommand(IUICommand command)
    {
        Logger.Log("Called");
        SettingsCommand settingsCommand = (SettingsCommand)command;
        string id =  settingsCommand.Id as string;
        switch (id)
            {
             case someID:
              {
               ShowSomeUI();
              } break;
    
             case otherID:
              {
               ShowSomeOtherUI();
              } break;
            }
    }
    
        protected void ShowSomeUI()
        {
    //Implement anything you want here
        }
    

    使用上面的类并让你的应用程序的第一个类继承自这个类,以便将命令添加到超级按钮栏并在点击时执行任何操作。

    P.S 如果不清楚或无法回答您的问题,请告诉我。

    【讨论】:

    • 感谢分享代码。它正在自定义设置魅力。我需要自定义“DEVICE CHARM”栏。
    猜你喜欢
    • 1970-01-01
    • 2013-09-06
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多