【问题标题】:How to open locally stored html file within flyout?如何在弹出窗口中打开本地存储的 html 文件?
【发布时间】:2014-09-20 08:50:24
【问题描述】:

我正在使用 windows 默认设置弹出添加一些自定义命令。但是现在我需要打开一个本地存储的 HTML 文件?我怎样才能做到这一点 ? 第二件事我想将我的弹出代码从 app.xaml.cs 移动到 app.xaml 任何帮助将不胜感激 以下是我的代码:

protected override void OnInitialize(IActivatedEventArgs args){

SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested; }

  void App_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
    {
        SettingsCommand settingsCommand = new SettingsCommand(
      "About",
      "About",    
      command =>
      {
         var flyout = new SettingsFlyout();
         flyout.Title = "About";

         string file = "ms-appx-web:///assets/about/about.html";


         flyout.Show();
      }
    );
    args.Request.ApplicationCommands.Add(settingsCommand);

    }

【问题讨论】:

    标签: xaml c#-4.0 windows-store-apps winrt-xaml


    【解决方案1】:

    至于您的第一个问题,是的,您绝对可以在 Settings Flyout 中打开本地存储的 HTML 页面。

    以下是我稍作修改的示例:

    private void App_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
        {
            SettingsCommand settingsCommand = new SettingsCommand(
                 "About",
                 "About",
                 command =>
                 {
                     var flyout = new SettingsFlyout();
                     flyout.Title = "About";
    
                     WebView wView = new WebView();
                     wView.Height = 700;
                     wView.Width = 300;
                     wView.Navigate(new Uri("ms-appx-web:///assets/About.html", UriKind.Absolute));
    
                     flyout.Content  = wView;
    
                     flyout.Show();
                 }
               );
            args.Request.ApplicationCommands.Add(settingsCommand);
    
        }
    

    不确定您问题的第二部分。也许你应该提出一个单独的问题。

    【讨论】:

      猜你喜欢
      • 2021-10-20
      • 2016-04-05
      • 1970-01-01
      • 2021-02-24
      • 1970-01-01
      • 1970-01-01
      • 2023-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多