Windows 8 如何在metro style应用程序中使用带MVVM灯的SettingsPane
我将MVVM Light框架用于metro风格的应用程序 我想在SettingsPane中添加一个命令以显示关于页面。“关于”页面应显示在右侧(如预装的日历应用程序)。对于测试,我在App.xaml.cs中的OnLaunched方法中添加了以下行:Windows 8 如何在metro style应用程序中使用带MVVM灯的SettingsPane,windows-8,mvvm-light,microsoft-metro,Windows 8,Mvvm Light,Microsoft Metro,我将MVVM Light框架用于metro风格的应用程序 我想在SettingsPane中添加一个命令以显示关于页面。“关于”页面应显示在右侧(如预装的日历应用程序)。对于测试,我在App.xaml.cs中的OnLaunched方法中添加了以下行: SettingsPane.GetForCurrentView().CommandsRequested += App_CommandsRequested; 以及以下事件处理程序: void App_CommandsRequested(Settings
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);
}
这是唯一的办法吗?
如何弹出“关于”页面?有什么建议吗
谢谢你的帮助!
MichaelMichael,尝试使用 您将需要以下内容:
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;
Michael,试着使用设置fLyout控件 您将需要以下内容:
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;
回答第一个问题:
据我所知,这是做那样事情的唯一方法 回答第二个问题:
要弹出“关于”页面,可以执行以下操作:
// 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);
我希望这能解决你的问题。回答第一个问题:
据我所知,这是做那样事情的唯一方法 回答第二个问题:
要弹出“关于”页面,可以执行以下操作:
// 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);
我希望这能解决您的问题。谢谢,我使用的是callisto的设置!谢谢,我用的是callisto的设置!谢谢你的回答!这对我有帮助!谢谢你的回答!这对我有帮助!