This is a migrated thread and some comments may be shown as answers.

FocusManager and RadWindow

5 Answers 166 Views
Window
This is a migrated thread and some comments may be shown as answers.
Patrick VADEL
Top achievements
Rank 1
Patrick VADEL asked on 07 Jun 2010, 11:04 AM
Hello,
I have a RadWindow with just a label and a textbox :

<telerik:RadWindow x:Class="TestWpf.MainWindow"    
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
        xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"    
        Header="Test" Width="400" Height="200"    
        FocusManager.FocusedElement="{Binding ElementName=tbxUser}">     
    <Grid>    
        <Label Content="User : " Height="28" Name="lblUser" />    
        <TextBox Height="23" Name="tbxUser" Width="120"/>     
    </Grid>    
</telerik:RadWindow> 

When I open the window I would have the focus in the textbox. So I add the FocusManager.FocusedElement attribute to the RadWindow but it doesn't work.
If I transform RadWindow to standard Window it works.
Is there another way to do this ?

Thanks in advance for your answer.

5 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 09 Jun 2010, 11:20 AM
Hello Patrick,

 You could add the following code to your window:

protected override void OnOpened(RoutedEventArgs args)
{
    base.OnOpened(args);
    this.Dispatcher.BeginInvoke(new Action(() => textBox.Focus()));
}

This will focus the TextBox once the window is opened.

Best wishes,
Miroslav Nedyalkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Patrick VADEL
Top achievements
Rank 1
answered on 09 Jun 2010, 03:10 PM

Hello,

Thank you, all works fine !

0
Kristoffer
Top achievements
Rank 1
answered on 30 Apr 2013, 02:45 PM
OnOpened is obsolete. Now what...?!
0
Miroslav Nedyalkov
Telerik team
answered on 02 May 2013, 01:11 PM
Hi Kristoffer,

You can focus your TextBox in the constructor of the RadWindow control right after the InitializeComponent method call like this:
InitializeComponent();
 
text.Focus();

Hope this helps.

Kind regards,
Miroslav Nedyalkov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dan
Top achievements
Rank 1
answered on 17 Nov 2013, 07:23 PM
nevermind :)
Tags
Window
Asked by
Patrick VADEL
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Patrick VADEL
Top achievements
Rank 1
Kristoffer
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Share this question
or