Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1032023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:01:19+00:00 2026-05-16T14:01:19+00:00

I am using a Silverlight usercontrol in my ASP.NET web app. The user control

  • 0

I am using a Silverlight usercontrol in my ASP.NET web app.
The user control has several autocomplete boxes and it seems that the enter key never fires the keydown event in any of them while it fires for other keys.

I’m assuming that autocomplete boxes must handle the enter key in a different way, perhaps for chosing an item from the list. – Thus it works with simple text boxes.

I was thinking about overriding the eventhandler in a new deriving control…

Have you guys found a solution for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:01:20+00:00Added an answer on May 16, 2026 at 2:01 pm

    Joe White is correct that some controls handle key events on their own, which has the effect of masking them to higher-level controls. If you take a look at the AutoCompleteBox in Reflector you will see that Enter, Escape, and F4 all cause something to happen and mark e.Handled = true.

    Unfortunately PreviewKeyDown does not exist in the Silverlight world.

    One way I have been able to prevent controls from responding to and capturing these key events is by subclassing the control and overriding the OnKeyDown method. Something like this would allow you to control whether or not the control reacts to the key events:

    public class MyAutoCompleteBox : AutoCompleteBox
    {
        public static readonly DependencyProperty HandleKeyEventsProperty = DependencyProperty.Register(
            "HandleKeyEvents",
            typeof(bool),
            typeof(MyAutoCompleteBox),
            new PropertyMetadata(true));
    
        public bool HandleKeyEvents
        {
            get { return (bool)GetValue(HandleKeyEventsProperty); }
            set { SetValue(HandleKeyEventsProperty, value); }
        }
    
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (this.HandleKeyEvents)
            {
                base.OnKeyDown(e);
            }
        }
    }
    

    You could then use the the HandleKeyEvents property in XAML to disable the control from handling them:

    <local:MyAutoCompleteBox HandleKeyEvents="False"/>
    

    This type of thing would prevent the base AutoCompleteBox from ever marking e.Handled = true and allow the event to bubble so your higher-level control could do something else with it. You could get more specific with which keys were handled if you wanted to prevent other KeyDown events (besides Enter) from breaking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When you create a Silverlight app using: <asp:Silverlight id=SlApp runat=server Source=~/ClientBin/SLApp.xap MinimumVersion=2.0 /> is
I am creating a basic image browsing application using Silverlight. Depending on the user's
I'm working on a Silverlight app using the MVVM pattern. My ViewModel currently consists
I'm writing a Silverlight app using the MVVM pattern. I have a main view
I'm using ADO.NET dataservices in a Silverlight application and since the silverlight libraries don't
I have just started using silverlight 2 beta and cannot find how to or
I've coded some smaller projects using Silverlight 2.0, which is fairly impressive. Does Silverlight
Would it be possible to show an image in full screen mode using silverlight.
When using a Silverlight-enabled WCF service, where is the best place to instantiate the
I'm using the Silverlight UnitTest framerwork does anyone have a good example have how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.