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