Telerik Forums
UI for WPF Forum
1 answer
76 views

Hello,

 

I need some advice about RadAutoCompleteBox.

When I click on RadAutoCompleteBox I want to see all possible results and then I will have a option to choose whether I want to select from them or start searching by typing.  Searching for text and then selecting works fine, but unfortunately searching with nothing in it doesn't work. When I click on RadAutoCompleteBox all the results are displayed, but I can't select anything from them until I type something. The hover selection works fine, I just can't select anything if RadAutoCompleteBox.SearchText is empty. Could you help me how to solve this? Thank you very much.

I am sending part of my the source code and example (WpfApp1.zip) where it also not working.


... 
 <controls:RadAutoCompleteBoxFilter x:Key="RadAutoCompleteBoxFilter" />
...
     <telerik:RadAutoCompleteBox Grid.Row="0"
                      x:Name="CaseAutoCompleteBox"
                      WatermarkContent="{x:Static rs:ResourceText.Start_Typing}"
                      ItemsSource="{Binding Suggestions}"
                      SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                      TextSearchMode="Contains"
                      TextSearchPath="Name"
                      DisplayMemberPath="Name"
                      AutoCompleteMode="SuggestAppend"
                      DropDownItemTemplate="{StaticResource CasesSearchAutoComplete}"
                      SelectionMode="Single"
                      SelectionChanged="CaseAutoCompleteBoxSelectionChanged"
                      PreviewMouseLeftButtonDown="OnPreviewMouseLeftButtonDown"
                      GotFocus="CaseAutoCompleteBox_OnGotFocus"
                      FilteringBehavior="{StaticResource RadAutoCompleteBoxFilter}"
                    
                      />



 public partial class AddMediaToCase 
 {
     public AddMediaToCase()
     {
         InitializeComponent();
         RadWindowInteropHelper.SetShowInTaskbar(this, true);
     }

     private void CaseAutoCompleteBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
     {
         var autoCompleteBox = sender as RadAutoCompleteBox;
         CaseInformationStackPanel.Visibility = autoCompleteBox.SelectedItem != null ? Visibility.Visible : Visibility.Collapsed;
     }

     private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
     {

         if (string.IsNullOrWhiteSpace(CaseAutoCompleteBox.SearchText))
         {
             CaseAutoCompleteBox.Populate(" ");
             
         }


     }

     private void CaseAutoCompleteBox_OnGotFocus(object sender, RoutedEventArgs e)
     {
         if (string.IsNullOrWhiteSpace(CaseAutoCompleteBox.SearchText))
         {
             
             CaseAutoCompleteBox.Populate(" ");
         }

     }
 }


  public class RadAutoCompleteBoxFilter : FilteringBehavior
  {
      public override IEnumerable<object> FindMatchingItems(string searchText, IList items,
          IEnumerable<object> escapedItems, string textSearchPath,
          TextSearchMode textSearchMode)
      {
          var result =
              base.FindMatchingItems(searchText, items, escapedItems, textSearchPath, textSearchMode) as
                  IEnumerable<object>;

          if (string.IsNullOrEmpty(searchText) || !result.Any())
          {
              return ((IEnumerable<object>)items).Where(x => !escapedItems.Contains(x));
          }

          return result;
      }
  }


 

Martin Ivanov
Telerik team
 answered on 30 Jul 2024
1 answer
253 views

Hi All,

I am trying to explore RadAutoSuggestBox (R2 2022 SP1 version) in my WPF MVVM application however I didn't find any support, how to purely bind (TextChanged event and few others) it with my ViewModel. My requirement is: Whenever user type, I have to make API call and then bind response with control's itemsource.

Any help will be appreciated.

Stenly
Telerik team
 answered on 04 Oct 2022
1 answer
280 views
Is it possible to use the Telerik Autocomplete controls but have the data come from a cloud API call?
Dinko | Tech Support Engineer
Telerik team
 answered on 03 Sep 2021
2 answers
151 views

Hi, have you any recommendation on how best to add a footer to the RadAutoSuggestBox?

E.g. "Showing 20 results of 100"

Thanks,

Richard

Martin Ivanov
Telerik team
 answered on 16 Jun 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?