Focus() Method Doesn't Work

Editors for WPF Forum

Posted 15 years ago by Andy Ver Murlen
Version: 9.1.0505
Platform: .NET 3.5
Environment: Windows XP (32-bit)
Avatar
I have just noticed that calling Focus() on an editor (at least the Int32 and DoubleEdit editors) does not work.

Consider the following sample. Click in the second editor, then click the "Set Focus" button. You will see that focus leaves the second editor, but does not move to the first editor.

<Window 
    x:Class="Sample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Editors="clr-namespace:ActiproSoftware.Windows.Controls.Editors;assembly=ActiproSoftware.Editors.Wpf30"
    Title="Window1"
    Width="600"
    Height="300"
    >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <Editors:Int32EditBox
            x:Name="uxTextBoxOne"
            Margin="3"
            Width="100"
            Height="21"
            />
        <Editors:Int32EditBox
            Margin="3"
            Grid.Row="1"
            Width="100"
            Height="21"
            />
        <Button
            Grid.Row="2"
            Content="Set Focus"
            Click="Button_Click"
            />
    </Grid>
</Window>

namespace Sample
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            uxTextBoxOne.Focus();
        }
    }
}

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks Andy, we've fixed this for the next maintenance release.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.