2012-06-13 30 views
0

我使用MVVM Light Framework作为metro风格的应用程序。如何在Metro风格的应用程序中使用SettingsPane和MVVM Light

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

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); 
} 

这是唯一的途径:

SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested; 

和事件处理程序下面? 如何飞出关于页面?有小费吗...?

感谢您的帮助! 迈克尔

回答

1

迈克尔,请尝试使用SettingsFlyout控制从Callisto project on github

你会需要这样的东西:

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; 
+0

谢谢,我使用callisto的SettingsFlyout! –

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); 

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

+0

感谢您的回答!它帮助到我! –

相关问题