Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Focus into an usercontrol element
Message
De
12/06/2009 05:10:37
 
 
À
11/06/2009 18:10:58
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01405014
Message ID:
01405434
Vues:
48
>>Hi all,
>>
>>Is there any way to set the focus to an WPF UserControl´s Element programaticaly?
>>
>>I can SetFocus to the UserControl, but how be set focus to one of its elements?
>>
>>Thanks in advance,
>>A. Llano
>
>My focus statements ussually end up looking like this:
>
>
>Dispatcher.BeginInvoke(DispatcherPriority.Input,
>                       new ThreadStart(delegate()
>                       {
>                       myUserControl.txtObject.Focus();
>                       }));
>
I came across this construct (on a SilverLight issue):
 Dispatcher.BeginInvoke(() =>
{
myUserControl.txtObject.Focus();
}
which looks like the same idea but just queuing on the same thread?

UPDATE: Just tried it and it doesn't compile anyway :-{ - but a modified version of your code using the same thread works OK....

UPDATE 2: This works:
Dispatcher.BeginInvoke(new Action(()=>myUserControl.txtObject.Focus();));
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform