Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
WPf user control load how to set foucs.

What I have tried:

load event use textbox.focus() . not work on page load at first time. but button click focus is display
Posted
Updated 11-Nov-17 0:43am

You haven't shown us the relevant code which makes it difficult to suggest but following threads should be sufficient for what you are looking for-
Set focus on a textbox control in UserControl in wpf - Stack Overflow[^]
Set focus on a textbox control in UserControl in wpf - Stack Overflow[^]

Hope, it helps :)
 
Share this answer
 
Setting focus in UserControls automatically can be tricky. This is the best solution that I have found and use:

Part 3: Shifting focus to the first available element in WPF - julmar.com[^]
 
Share this answer
 
Finally Got Solutions

usercontrol property added se --- Focusable="false"


grid add property --
Focusable="True" Cursor="Hand"
 
Share this answer
 
UserControl Property added in xaml
Focusable="false"


grid property added in xaml

Focusable="True" Cursor="Hand"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900