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 6066735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:31:57+00:00 2026-05-23T09:31:57+00:00

I have some textboxes where I would like focus to behave a little differently

  • 0

I have some textboxes where I would like focus to behave a little differently than normal for a WPF application. Basically, I would like them to behave more like a textbox behaves on a webpage. That is, if I click anywhere outside of the textbox, it will lose its focus. What is the best way to do so?

If the answer is to programmatically remove focus, what is the best way to detect a Mouseclick outside of the bounds? What if the element I’m clicking on will be the new recipient of focus?

  • 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-23T09:31:57+00:00Added an answer on May 23, 2026 at 9:31 am

    Rather than adding new control to window, I think you should give your Grid a name and react to the MouseDown event on your window, moving the focus to the Grid itself. Something like this:

    <Window x:Class="WpfApplication1.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="Window1" 
        Height="412" Width="569" 
        MouseDown="Window_MouseDown" 
        Name="window1">
    
        <Grid ShowGridLines="False" 
              Background="#01FFFFFF"
              KeyDown="Grid_KeyDown" 
              Name="grid1" 
              Focusable="True">
    
              <TextBox Width="120" Margin="117,61,0,0" 
                       Name="textBox1" 
                       VerticalAlignment="Top" 
                       HorizontalAlignment="Left"/>
        </Grid>
    </Window>
    

    code behind:

    private void window1_MouseDown(object sender, MouseButtonEventArgs e)
    {
        grid1.Focus();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some comboboxes and some textboxes on a form i would like to
I have a dropdown list and some textboxes (5). I would like to pass
I have several forms with many textboxes/comboboxes, and I would like to have the
I have a login-page and would like the Username textbox focus when page loads.
In WPF, when a user gets focus in a TextBox , I would like
I have some textboxes on a page and I want to click a link
I have added some dynamic textboxes upon a button click. I need the values
I have a client report (rdlc) and want to repeat some textboxes in every
In my fieldset I have labels next (side) to my textboxes, but for some
I have to align a textbox and some text, at about 30 degrees, like

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.