Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 76418

Which is the best way of binding Focus?

$
0
0

I want to load some data from server, and then set the focus to a SearchBar control.

I have created a custom control with a bindable property, checking the value received, and if true, I call Focus() method, but it doesn't work.

Here is my code:

public class AppSearchBar : SearchBar
{
    public static readonly BindableProperty RaiseFocusProperty =
        BindableProperty.Create<AppSearchBar, bool>(p => p.RaiseFocus, default(bool));

    public bool RaiseFocus
    {
        get { return (bool)GetValue(RaiseFocusProperty); }
        set
        {
            if (value)
                this.Focus();

            SetValue(RaiseFocusProperty, value);
        }
    }
}

What can I do?


Viewing all articles
Browse latest Browse all 76418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>