Beispiel #1
0
        public static DelegateCommand SearchClickedCommand()
        {
            DelegateCommand cmd = new DelegateCommand(() =>
            {
                (_splitView.Resources["SearchButtonClickedStoryBoard"] as Storyboard).Begin();
                _searchBox.Focus(FocusState.Programmatic);
                (shortcuts.Items[3] as Shortcut).ShortcutCommand.IsEnabled = false;
                _searchBox.LostFocus += (sender, e) => (shortcuts.Items[3] as Shortcut).ShortcutCommand.IsEnabled = true;
            });

            return(cmd);
        }
 private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
 {
     AddToken(args.SelectedItem);
     sender.Text = string.Empty;
     sender.Focus(FocusState.Programmatic);
     SuggestionChosen?.Invoke(sender, args);
 }
Beispiel #3
0
        /// <summary>Initializes a new instance of the <see cref="SearchHamburgerItem"/> class.</summary>
        public SearchHamburgerItem()
        {
            AutoSuggestBox           = new AutoSuggestBox();
            AutoSuggestBox.QueryIcon = new SymbolIcon {
                Symbol = Symbol.Find
            };
            AutoSuggestBox.AutoMaximizeSuggestionArea = false;
            AutoSuggestBox.Loaded         += delegate { AutoSuggestBox.PlaceholderText = PlaceholderText; };
            AutoSuggestBox.QuerySubmitted += OnQuerySubmitted;
            AutoSuggestBox.GotFocus       += OnGotFocus;

            Content = AutoSuggestBox;
            Icon    = new SymbolIcon(Symbol.Find);

            CanBeSelected   = false;
            ShowContentIcon = false;
            PlaceholderText = string.Empty;

            Click += (sender, args) =>
            {
                args.Hamburger.IsPaneOpen = true;
                args.Hamburger.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    AutoSuggestBox.Focus(FocusState.Programmatic);
                });
            };
        }
        /// <summary>Initializes a new instance of the <see cref="SearchHamburgerItem"/> class.</summary>
        public SearchHamburgerItem()
        {
            AutoSuggestBox = new AutoSuggestBox();
            AutoSuggestBox.QueryIcon = new SymbolIcon { Symbol = Symbol.Find };
            AutoSuggestBox.AutoMaximizeSuggestionArea = false;
            AutoSuggestBox.Loaded += delegate { AutoSuggestBox.PlaceholderText = PlaceholderText; };
            AutoSuggestBox.QuerySubmitted += OnQuerySubmitted;
            AutoSuggestBox.GotFocus += OnGotFocus;

            Content = AutoSuggestBox;
            Icon = new SymbolIcon(Symbol.Find);

            CanBeSelected = false;
            ShowContentIcon = false;
            PlaceholderText = string.Empty;
            
            Click += (sender, args) =>
            {
                args.Hamburger.IsPaneOpen = true;
                args.Hamburger.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    AutoSuggestBox.Focus(FocusState.Programmatic);
                });
            };
        }
Beispiel #5
0
 private void OnNavigationRootPageKeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (!e.Handled && e.Key == Windows.System.VirtualKey.E)
     {
         AutoSuggestBox box = this.GetDescendantsOfType <PageHeader>().First().controlsSearchBox;
         var            f   = box.Focus(FocusState.Programmatic);
     }
 }
Beispiel #6
0
        private void AsbServerPath_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            FolderItem suggestion = args.ChosenSuggestion is FolderItem ? (FolderItem)args.ChosenSuggestion : (FolderItem)sender.Items[0];
            string     parentPath = Utils.GetParentPath(sender.Text);

            sender.Text = Utils.JoinPaths(parentPath, suggestion.Name) + '\\';
            sender.Focus(FocusState.Keyboard);
        }
Beispiel #7
0
        private void cboxFrom_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            sender.Text = (args.SelectedItem as CountryList).Name;

            var cb = sender as AutoSuggestBox;

            ReadCsv(cb.Tag as string);

            sender.Focus(FocusState.Unfocused);
        }
Beispiel #8
0
        private async void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            QuerySubmitted?.Invoke(sender, args);

            if (args.ChosenSuggestion != null)
            {
                sender.Text = string.Empty;
                await AddToken(args.ChosenSuggestion);

                sender.Focus(FocusState.Programmatic);
            }
            else if (!string.IsNullOrWhiteSpace(args.QueryText))
            {
                sender.Text = string.Empty;
                await AddToken(args.QueryText);

                sender.Focus(FocusState.Programmatic);
            }
        }
        private void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            if (args.QueryText != string.Empty)
            {
                AddToken(args.QueryText);
                sender.Text = string.Empty;
                sender.Focus(FocusState.Programmatic);
            }

            QuerySubmitted?.Invoke(sender, args);
        }
 private void SearchButton_Click(object sender, RoutedEventArgs e)
 {
     if ((sender as Button).Name == PART_ShowSearchButton)
     {
         ShowSearch();
         _autoSuggestBox.Focus(FocusState.Programmatic);
     }
     else
     {
         HideSearch();
     }
 }
        public async Task When_Text_Changed_And_Focused_Should_Open_Suggestion_List()
        {
            var SUT = new AutoSuggestBox();

            SUT.ItemsSource = new List <string>()
            {
                "ab", "abc", "abcde"
            };
            WindowHelper.WindowContent = SUT;
            await WindowHelper.WaitForIdle();

            var textBox = (TextBox)SUT.GetTemplateChild("TextBox");

            SUT.Focus(FocusState.Programmatic);
            textBox.IsFocused.Should().BeTrue();
            SUT.Text = "a";
            SUT.IsSuggestionListOpen.Should().BeTrue();
        }
        private static async void asb_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            sender.ItemsSource = null;
            if (args.ChosenSuggestion == null || autoCompleteFinished(args.ChosenSuggestion))
            {
                var command = GetSubmitCommand(sender);
                if (command.CanExecute(args.QueryText))
                {
                    command.Execute(args.QueryText);
                }
            }
            else
            {
                sender.Focus(FocusState.Keyboard);
                // workaround for IME candidates, which will clean input.
                await sender.Dispatcher.YieldIdle();

                sender.Text = args.ChosenSuggestion.ToString();
            }
        }
Beispiel #13
0
        public async Task StartSearch(string startingText = null)
        {
            if (_searchBox == null || _searchBox.Visibility == Visibility.Visible)
            {
                return;
            }

            var currentSearchText = _searchBox.Text;

            _searchBox.Text = string.Empty;

            if (!string.IsNullOrWhiteSpace(startingText))
            {
                _searchBox.Text = startingText;
            }
            else
            {
                _searchBox.Text = currentSearchText;
            }

            _searchButton.Visibility = Visibility.Collapsed;
            _searchBox.Visibility    = Visibility.Visible;

            _searchBox.Focus(FocusState.Programmatic);

            // We need to wait for the textbox to be created to focus it (only first time).
            TextBox innerTextbox = null;

            do
            {
                innerTextbox = _searchBox.FindDescendant <TextBox>();
                innerTextbox?.Focus(FocusState.Programmatic);

                if (innerTextbox == null)
                {
                    await Task.Delay(150);
                }
            }while (innerTextbox == null);
        }
Beispiel #14
0
        private async void AutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            Owner.RaiseQuerySubmitted(sender, args);

            object chosenItem = null;

            if (args.ChosenSuggestion != null)
            {
                chosenItem = args.ChosenSuggestion;
            }
            else if (!string.IsNullOrWhiteSpace(args.QueryText))
            {
                chosenItem = args.QueryText;
            }

            if (chosenItem != null)
            {
                await Owner.AddTokenAsync(chosenItem); // TODO: Need to pass index?

                sender.Text = string.Empty;
                Owner.Text  = string.Empty;
                sender.Focus(FocusState.Programmatic);
            }
        }
 public void SetFocus()
 {
     _autoSuggestBox?.Focus(FocusState.Programmatic);
 }
Beispiel #16
0
 private void Control_Loaded(object sender, RoutedEventArgs e)
 {
     _searchBox.Focus(FocusState.Programmatic);
 }
 /// #######################################################################################
 ///  Search button
 private void NavView_Search_Tapped(object sender, TappedRoutedEventArgs e)
 {
     AutoSuggestBox.Visibility = Visibility.Visible;
     AutoSuggestBox.Focus(FocusState.Programmatic);
 }
Beispiel #18
0
 private async void SearchKeyTextBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
 {
     sender.Focus(FocusState.Pointer);
     await GalleryListViewModel.Load();
 }