当前位置:
  1. 魔豆IT网
  2. 系统教程
  3. windows8
  4. 正文

今日 10 点,上海,微软中国在 Windows 8 10 月 26 日的全球正式发布前,带我们先睹这全新的系统和硬件的魅力所在!

微软全球 Windows 与 Windows Live 事业部总裁 Steven Sinofsky 和微软全球资深副总裁、大中华区董事长兼首席执行官贺乐赋( Ralph Haupter )共同出席了庆祝活动。

漫长的等待,Win 8 终于快发布了。期待中。。。

下面是我自己学习的Win 8小Sample,为了以后方便学习,特做一些记录。

效果如下图: 右边添加了三个命令,分别为:First Custom Command,Second Custom Command,Third Custom Command。

图1-设置面版

图2-自定义用户控件 右边的控件是用户自己定义的控件,我这里定义的很简单。

关键代码如下:

1、添加命令道设置面版中. 分别添加了三个命令。以及三个命令对应的操作。这里定义的很简单,自己可以定义的更复杂一些。

privatevoidAddCommandToSettingPanel(){//AddthreecommandtoSettingPanel.SettingsCommandcmd1=newSettingsCommand("1","FirstCustomCommand",c=>{SettingPanelUCuc=newSettingPanelUC();uc.Show();});SettingsCommandcmd2=newSettingsCommand("2","SecondCustomCommand",c=>{ShowMessageTBK.Text="SecondCustomCommandClick";});SettingsCommandcmd3=newSettingsCommand("3","ThirdCustomCommand",c=>{ShowMessageTBK.Text="ThirdCustomCommandClick";});//AddcommandinCommandsRequestedEvent.SettingsPane.GetForCurrentView().CommandsRequested+=(sp,arg)=>{arg.Request.ApplicationCommands.Add(cmd1);arg.Request.ApplicationCommands.Add(cmd2);arg.Request.ApplicationCommands.Add(cmd3);};}

2、显示设置面版

privatevoidShowSettingsPanel(objectsender,RoutedEventArgse){//ShowSettingPanelWindows.UI.ApplicationSettings.SettingsPane.Show();}

3、自定义控件关键代码:

publicsealedpartialclassSettingPanelUC:UserControl{Popuppop=null;publicSettingPanelUC(){this.InitializeComponent();this.Width=360d;this.Height=Window.Current.Bounds.Height;this.pop=newPopup();this.pop.Child=this;this.pop.IsLightDismissEnabled=true;//Maketheusercontrolisontheright.pop.HorizontalOffset=Window.Current.Bounds.Width-this.Width;pop.VerticalOffset=0d;//Animationfortheusercontrol.this.Transitions=newWindows.UI.Xaml.Media.Animation.TransitionCollection();EdgeUIThemeTransitionet=newEdgeUIThemeTransition();et.Edge=EdgeTransitionLocation.Right;this.Transitions.Add(et);}///<summary>///显示控件///</summary>publicvoidShow(){if(pop!=null){pop.IsOpen=true;}}///<summary>///隐藏控件///</summary>publicvoidHide(){if(pop!=null){pop.IsOpen=false;}}privatevoidBack(objectsender,RoutedEventArgse){this.Hide();Windows.UI.ApplicationSettings.SettingsPane.Show();}}

总结:Win 8 设置面版还是挺简单的,我这里只是学习写了一些简单的东西,并记录下,方便自己以后再次学习。当然,里面的自定义控件的复杂逻辑还是要靠自己去写的。

相关阅读

  • 暂无推荐

《》由网友“”推荐。

转载请注明: