Windows 8 系列 — ApplicationSettings –隨筆

來源:互聯網
上載者:User
//向設定面板加入事件
SettingsPane.GetForCurrentView().CommandsRequested += MainPage_CommandsRequested;
 // 點擊時觸發,添加一項        void MainPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)        {            //定義執行處理事件            UICommandInvokedHandler handle = new UICommandInvokedHandler(onSettingsCommand);            //定義設定命令項            SettingsCommand generalCommand = new SettingsCommand("generalSettings", "general", handle);            //將命令項添加到設定集合            args.Request.ApplicationCommands.Add(generalCommand);         }
 //執行命令項事件        void onSettingsCommand(IUICommand command)        {            SettingsCommand settingsCommand = (SettingsCommand)command;            showBlock.Text = settingsCommand.Label;        }
//定義popup表單 private Popup settingsPopup; void onSettingsCommand1(IUICommand command)        {            settingsPopup = new Popup();
       //popup關閉時 settingsPopup.Closed += settingsPopup_Closed; Window.Current.Activated += Current_Activated; settingsPopup.IsLightDismissEnabled = true; settingsPopup.Width = settingsWidth; settingsPopup.Height = windowBounds.Height; settingsPopup.ChildTransitions = new TransitionCollection(); settingsPopup.ChildTransitions.Add(new PaneThemeTransition() { Edge = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? EdgeTransitionLocation.Right : EdgeTransitionLocation.Left }); //將使用者xmal 添加到Popup中 SettingsFlyout mypane = new SettingsFlyout(); mypane.Width = settingsWidth; mypane.Height = windowBounds.Height; settingsPopup.Child = mypane; settingsPopup.SetValue(Canvas.LeftProperty, SettingsPane.Edge == SettingsEdgeLocation.Right ? (windowBounds.Width - settingsWidth) : 0); settingsPopup.SetValue(Canvas.TopProperty, 0); settingsPopup.IsOpen = true; }
void settingsPopup_Closed(object sender, object e)        {            Window.Current.Activated -= Current_Activated;        }
 void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)        {            //throw new NotImplementedException();            if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)            {                settingsPopup.IsOpen = false;            }        }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.