OpenDropDownOnFocus

7 posts, 0 answers
  1. Guy
    Guy avatar
    3 posts
    Member since:
    Dec 2012

    Posted 05 Mar 2013 Link to this post

    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
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 08 Mar 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Guy
    Guy avatar
    3 posts
    Member since:
    Dec 2012

    Posted 10 Mar 2013 Link to this post

    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
  5. kapil akhia
    kapil akhia avatar
    1 posts
    Member since:
    Dec 2009

    Posted 19 Feb 2014 in reply to Guy Link to this post

    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
  6. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 24 Feb 2014 Link to this post

    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
  7. Sebastian
    Sebastian avatar
    2 posts
    Member since:
    May 2011

    Posted 01 Aug 2014 in reply to Yana Link to this post

    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!
  8. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 04 Aug 2014 Link to this post

    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.
     
Back to Top
UI for WPF is Visual Studio 2017 Ready