This is a migrated thread and some comments may be shown as answers.

OpenDropDownOnFocus

6 Answers 347 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Guy
Top achievements
Rank 1
Guy asked on 05 Mar 2013, 02:15 PM
Hi

We would like to implement OpenDropDownOnFocus for AutoCompleteBox ( RadComboBox has this property and this behavior).
We override the default AutoCompeteBox Style .
How can we do that?
Thanks

6 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 08 Mar 2013, 02:18 PM
Hi Guy,

In order to achieve the described behavior when the AutoCompleteBox gets the focus you will need to customize the FilteringBehavior of the control in such a way that it returns all the items from the ItemsSource of the control when the SearchText is empty and then call the Populate() method of control in the GotFocus event.

You can download our similar SDK example OpenWithDropDownButton which demonstrates the same scenario but on button Click event. All you need to change in that example to make it work when the control is focused is move the:
this.RadAutoCompleteBox.Populate(this.RadAutoCompleteBox.SearchText);

line of code to the GotFocus event of the RadAutoCompleteBox control. Hope this is helpful.

Regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Guy
Top achievements
Rank 1
answered on 10 Mar 2013, 08:54 AM
Hi

To achieve the desired behavior the following code should be added to GotFocus event.

    Popup popup = (Popup)this.RadAutoCompleteBox.Template.FindName("PART_Popup", this.RadAutoCompleteBox);

            this.RadAutoCompleteBox.Populate(this.RadAutoCompleteBox.SearchText);

            popup.IsOpen = true;


Thanks.
Guy
0
kapil akhia
Top achievements
Rank 1
answered on 19 Feb 2014, 03:41 PM
Hi,

I need to display all dropdown item list on radautocomplete focus, if no text it typed.

Is it possible in ASP.NET AJAX ?

Regards,

Kapil Akhia
0
Yana
Telerik team
answered on 24 Feb 2014, 10:53 AM
Hi Kapil,

I'd ask you to post the question in the ASP.NET AJAX forums instead.

Thank you for the understanding.

Regards,
Yana
Telerik
0
Sebastian
Top achievements
Rank 1
answered on 01 Aug 2014, 06:05 PM
Hi,

I expanded my Dropdown with a click effect like this:
<telerik:RadAutoCompleteBox x:Name="ValuesComboBox" Grid.Column="1" Grid.ColumnSpan="3" KeyUp="OnKeyUp" GotFocus="OnGotFocus" PreviewMouseLeftButtonDown="OnPreviewMouseLeftButtonDown" FilteringBehavior="{StaticResource EmptyTextFilteringBehavior}" SelectedItems="{Binding SelectedValues}" ItemsSource="{Binding Values}" SelectionMode="Multiple" TextSearchMode="Contains" TextSearchPath="Name" AutoCompleteMode="Suggest" />
 
private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
   ValuesComboBox.Populate(ValuesComboBox.SearchText);
}

But now, if the dropdown was opened like this, you can move the window and the dropdown stays opened and does not move with the window. What´s the mistake?

Thanks!
0
Vladi
Telerik team
answered on 04 Aug 2014, 07:22 AM
Hi Sebastian,

Thank you for contacting us.

We managed to reproduce the scenario and it looks there is an issue in the current version of RadAutoCompleteBox when the Populate method is called from it's PreviewMouseLeftButtonDown or GotFocus events. In that scenario if the DropDown of the control is opened and the parent Window is directly moved that DropDown is not closed. As a workaround you could implement a logic that closes any opened Popup instances when the parent window is moved. To implement such workaround you could use the LocationChanged event of the Window and in that event simply set the IsOpen property of any Popup instance that is a child of the RadAutoCompleteBox. The next code snippet show the described workaround:
<Window LocationChanged="OnWindowLocationChanged" ...>
      <telerik:RadAutoCompleteBox x:Name="AutoCompleteBox" .../>
</Window>

and in the event handler:
private void OnWindowLocationChanged(object sender, EventArgs e)
{
    var popups = this.AutoCompleteBox.ChildrenOfType<Popup>();
    foreach (var popup in popups)
    {
        if (popup.IsOpen)
        {
            popup.IsOpen = false;
        }
    }
}


We logged this issue in our feedback portal where you can track its status. I updated your Telerik points for bringing this to our attention.

Regards,
Vladi
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
AutoCompleteBox
Asked by
Guy
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Guy
Top achievements
Rank 1
kapil akhia
Top achievements
Rank 1
Yana
Telerik team
Sebastian
Top achievements
Rank 1
Share this question
or