0

我将 MVVM Light Framework 用于 Metro 风格的应用程序。

我想在 SettingsPane 中添加一个命令来显示关于页面。关于页面应显示在右侧(如预装的日历应用程序)。对于测试,我在 App.xaml.cs 的 OnLaunched 方法中添加了以下行:

SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested;

和以下事件处理程序:

void App_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
    // Add an About command
    var about = new SettingsCommand("about", "About", (handler) =>
    {
        // show about page in flyout transition...
    });

    args.Request.ApplicationCommands.Add(about);
}

这是唯一的方法吗?如何弹出关于页面?有小费吗...?

感谢帮助!迈克尔

4

2 回答 2

2

回答第一个问题:
据我所知,这是做类似事情的唯一方法。

要回答第二个问题:
要弹出关于页面,您可以这样做:

// Add an About command
var about = new SettingsCommand("about", "About", (handler) =>
{
    // show about page in flyout transition...
    var currentPane = new AboutPane(); // the aboutpane is a page
    var myPopup = new Popup();

    myPopup.IsLightDismissEnabled = true;
    myPopup.Width = _settingsWidth;
    myPopup.Height = Window.Current.Bounds.Height;

    myPopup.Width = 346;
    myPopup.Height = Window.Current.Bounds.Height;

    myPopup.Child = currentPane;
    myPopup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 346);
    myPopup.SetValue(Canvas.TopProperty, 0);
    myPopup.IsOpen = true;
});

args.Request.ApplicationCommands.Add(about);

我希望这能解决你的问题。

于 2012-07-06T12:41:30.613 回答
1

Michael,尝试使用github 上 Callisto 项目中的 SettingsFlyout 控件

您将需要类似的东西:

using Callisto.Controls;

//... other code here

//in your callback for handling the settings command:

// show about page in flyout transition...
var settingsFlyout = new SettingsFlyout();
settingsFlyout.Content = new AboutControl(); //this would be your own user control that contains the about page content

settingsFlyout.IsOpen = true;
于 2012-06-14T00:27:50.947 回答