A

1 Answer 38 Views
AutoCompleteBox
Jongmin Lee
Top achievements
Rank 1
Jongmin Lee asked on 31 May 2024, 03:23 AM | edited on 31 May 2024, 03:36 AM
Dear All,

I am using the RadAutoCompleteBox as follows. I would like to display all Products when pressing the "Keyboard Down Arrow" on the RadAutoCompleteBox. Is this possible?

 

<telerik:RadAutoCompleteBox Height="23" Width="180" Background="#FFEDF4AB" Margin="3,0,0,0" ItemsSource="{Binding Products}" SelectedItem="{Binding SelectedProductItem, Mode=TwoWay}" SelectionMode="Single" TextSearchMode="StartsWith" SearchText="{Binding Name, Mode=TwoWay}" TextSearchPath="Name" DisplayMemberPath="Name" AutoCompleteMode="Suggest" > <telerik:RadAutoCompleteBox.DropDownItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="Black" Width="200" /> </StackPanel> </DataTemplate> </telerik:RadAutoCompleteBox.DropDownItemTemplate> <Behaviors:Interaction.Triggers> <Behaviors:EventTrigger EventName="SelectionChanged"> <Behaviors:InvokeCommandAction Command="{Binding SelectProductCommand}" /> </Behaviors:EventTrigger> </Behaviors:Interaction.Triggers> </telerik:RadAutoCompleteBox>

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 31 May 2024, 08:23 AM

Hello Jongmin Lee,

I have attached a sample project that shows this. I have used a custom filtering behavior to populate the items without search text. 

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Jongmin Lee
Top achievements
Rank 1
commented on 31 May 2024, 12:41 PM

Hi Dimitar,

Thank you for your advice; it has been very helpful for my project.

Currently, I am not using the code Behind you mentioned and need to send "KeyEventArgs" to a command via MVVM. Below is my code snippet, but I can't find the path for "KeyEventArgs." Could you help me find a way to implement the KeyDown event with arguments?

Thank you for your assistance.

 

<Behaviors:EventTrigger EventName="PreviewKeyDown">  

<Behaviors:InvokeCommandAction Command="{Binding KeyDownCommands}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=telerik:RadAutoCompleteBox}, Path=xxxxx }"/>

</Behaviors:EventTrigger>

Jongmin Lee
Top achievements
Rank 1
commented on 31 May 2024, 08:12 PM

Hi Dimitar,

I solved this issue by creating a component that inherits from RadAutoCompleteBox.
Thanks for sharing your idea. it is very helpful to my case.

public class BAWAutoCompleteBox : RadAutoCompleteBox
{
    public BAWAutoCompleteBox()
    {
        this.FilteringBehavior = new EmptyTextFilteringBehavior();
        this.PreviewKeyDown += AutoComplete_PreviewKeyDown;
    }
 
    private void AutoComplete_PreviewKeyDown(object senderKeyEventArgs e)
    {
        if (e.Key == Key.Down && (this.IsDropDownOpen == false))
        {
            this.IsDropDownOpen = false;
 
            this.Focus();
            this.Populate(this.SearchText);
        }
    }
}
Dimitar
Telerik team
commented on 04 Jun 2024, 06:01 AM

Hi Jongmin, 

I am glad that you have found a solution for this. Do not hesitate to contact us if you have other questions.

Tags
AutoCompleteBox
Asked by
Jongmin Lee
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or