AutocompleteBox Click Event

2 posts, 0 answers
  1. Minh
    Minh avatar
    1 posts
    Member since:
    Dec 2017

    Posted 19 Dec 2017 Link to this post

    Hi, I was looking to trigger an event when my autocomplete box is clicked into. GotFocus works perfectly but is there a way to have the event not fire when a token is clicked on/ Removed.

    Kind regards,
  2. Dilyan Traykov
    Dilyan Traykov avatar
    875 posts

    Posted 22 Dec 2017 Link to this post

    Hello Minh,

    To have better control over which part of the RadAutoCompleteBox should trigger your custom logic, you can handle the MouseLeftButtonDownEvent of the control in a similar fashion:

    public MainWindow()
        this.autoComplete.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(AutoComplete_MouseLeftButtonDown), true);
    private void AutoComplete_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        var source = e.OriginalSource as FrameworkElement;
        // if (source.ParentOfType<RadWatermarkTextBox>() != null)
        if (source.ParentOfType<RadAutoCompleteBoxItem>() == null)

    The above two examples will show a message box if the actual text box of the control or anything except an autocomplete box item is clicked. You're free, of course, to further modify this to suit your needs.

    Please let me know whether such an approach would work for you.

    Dilyan Traykov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top