/// <summary> /// Raises the WindowCreated event. /// </summary> /// <param name="args">The <see cref="WindowCreatedEventArgs"/> instance containing the event data.</param> protected override void OnWindowCreated(WindowCreatedEventArgs args) { if (AppManifestHelper.IsSearchDeclared()) { // Register the Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted // event in OnWindowCreated to speed up searches once the application is already running SearchPane.GetForCurrentView().QuerySubmitted += OnQuerySubmitted; } }
/// <summary> /// Determines if the Show On Keyboard Input feature is enabled or not. /// </summary> /// <returns> /// <c>true</c> if the Show On Keyboard Input feature is enabled; otherwise, <c>false</c>. /// </returns> public bool IsShowOnKeyboardInputEnabled() { if (!AppManifestHelper.IsSearchDeclared()) { return(false); } return(SearchPane.GetForCurrentView().ShowOnKeyboardInput); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { var rootFrame = await InitializeFrameAsync(args); // If the app is launched via the app's primary tile, the args.TileId property // will have the same value as the AppUserModelId, which is set in the Package.appxmanifest. // See http://go.microsoft.com/fwlink/?LinkID=288842 string tileId = AppManifestHelper.GetApplicationId(); if (rootFrame != null && (rootFrame.Content == null || (args != null && args.TileId != tileId))) { OnLaunchApplication(args); } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Called to present the Flyout view. /// </summary> /// <param name="parameter">Optional parameter for the caller to pass into the view.</param> /// <param name="successAction">Method to be invoked on successful completion of the user task in the Flyout.</param> public void Open(object parameter, Action successAction) { // Create a new Popup to display the Flyout _popup = new Popup(); _popup.IsLightDismissEnabled = true; var frame = Window.Current.Content as Frame; if (frame != null) { var page = frame.Content as Page; if (page != null) { var flowDirection = page.FlowDirection; if (flowDirection == FlowDirection.LeftToRight) { _popup.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - FlyoutSize); } else { _popup.SetValue(Canvas.LeftProperty, FlyoutSize); } } } _popup.SetValue(Canvas.TopProperty, 0); // Handle the Closed & Activated events of the Popup _popup.Closed += OnPopupClosed; Window.Current.Activated += OnWindowActivated; // Update the Flyout dimensions Width = FlyoutSize; Height = Window.Current.Bounds.Height; // Add animations for the panel. _popup.ChildTransitions = new TransitionCollection(); _popup.ChildTransitions.Add(new PaneThemeTransition() { Edge = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? EdgeTransitionLocation.Right : EdgeTransitionLocation.Left }); // Place the Flyout inside the Popup and open it _popup.Child = this; _popup.IsOpen = true; // If the Flyout has a DataContext, call the viewModel.Open method and set the set the Close and GoBack actions for future use var viewModel = DataContext as IFlyoutViewModel; if (viewModel != null) { viewModel.CloseFlyout = Close; viewModel.GoBack = GoBack; viewModel.Open(parameter, successAction); } // First verify if Search is enabled in the manifest, to be able to call the SearchPane class. // If SearchOnKeyboardInput is enabled, disable it. Also, save the current state. if (!AppManifestHelper.IsSearchDeclared()) { return; } var searchPane = SearchPane.GetForCurrentView(); _wasSearchOnKeyboardInputEnabled = searchPane.ShowOnKeyboardInput; if (_wasSearchOnKeyboardInputEnabled) { searchPane.ShowOnKeyboardInput = false; } }