AvaloniaUI / Avalonia.Xaml.Behaviors

Port of Windows UWP Xaml Behaviors for Avalonia Xaml.
MIT License
385 stars 46 forks source link

Textbox focus #131

Closed vmiwouter closed 1 year ago

vmiwouter commented 1 year ago

Since rc1 cant focus a textbox anymore:

System.ArgumentException: 'Cannot find method named Focus on object of type Avalonia.Controls.TextBox that matches the expected signature.'

xaml: `

`

Via code behind it still works: ` txtUsername.Loaded += OnActivated;

        void OnActivated(object? sender, RoutedEventArgs e)
        {
            txtUsername.Focus();
        }`
wieslawsoltes commented 1 year ago

It's because Focus method in avalonia now requires additional arguments. So CallMethodAction will not work this way.

wieslawsoltes commented 1 year ago

You can use FocusControlAction, I've added TargetControl support.