FocusManager and RadWindow

6 posts, 0 answers
  1. Patrick VADEL
    Patrick VADEL avatar
    2 posts
    Member since:
    Oct 2009

    Posted 07 Jun 2010 Link to this post

    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.
  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 09 Jun 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Patrick VADEL
    Patrick VADEL avatar
    2 posts
    Member since:
    Oct 2009

    Posted 09 Jun 2010 Link to this post

    Hello,

    Thank you, all works fine !

  5. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 30 Apr 2013 Link to this post

    OnOpened is obsolete. Now what...?!
  6. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 02 May 2013 Link to this post

    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.

  7. Dan
    Dan avatar
    2 posts
    Member since:
    Dec 2012

    Posted 17 Nov 2013 Link to this post

    nevermind :)
Back to Top
UI for WPF is Visual Studio 2017 Ready