I have a button on a form in a PCL-based iOS app which when clicked should display a pre-populated picker by giving it focus from the button click handler. It works sometimes but not always, is there a reason for this? I've used the same technique to display a datepicker and it works 100% of the time so I'm wondering why the picker is hit and miss? A forum search revealed a couple of related questions but not an answer/solution that was confirmed as working. Can anyone explain why I'm seeing this issue and/or offer a solution? Thanks.
I have opened a bug on bugzilla for "focus" on Date and Time Picker some days ago
With Buttons, picker.Focus works fine (for me).
With Label + TapGestures, it does not work fine...
Answers
I have opened a bug on bugzilla for "focus" on Date and Time Picker some days ago
With Buttons, picker.Focus works fine (for me).
With Label + TapGestures, it does not work fine...
Actually I was trying to use a Label and TapGesture myself (not a Button, my mistake) so I was experiencing the same issues as you, I guess. I have now changed it to a button (made to look like a Label) and it's working great! Thanks for your reply.
Do make sure you're on main thread
http://stackoverflow.com/questions/28784939/trigger-xamarin-forms-picker
I had similar issues where timepicker is not showing up after DisplayAlert, I fixed by doing:
Device.BeginInvokeOnMainThread (() => {
yourPicker.Focus ();
});
You saved my life. This buggy gesture recognizer
Help to solve my issue to. Thank you sir!
It doesn't work for me, I mean on the UWP part..
It does not work for me either in a UWP and Windows 8.1 app. I haven't tested on any physical phones or emulators yet though. I'm using Xamarin.Forms 2.3.4-pre1. I filed a bug for this problem at https://bugzilla.xamarin.com/show_bug.cgi?id=52266
I had the scenario where I need to show picker on icon tap.
Below code Worked for me in Xamarin forms
Device.BeginInvokeOnMainThread (() => {
yourPicker.Focus ();
});
This worked for me on IOS. Thanks a ton!! So many little quirks and bugs, very frustrating to get past them.
This worked for me. Thanks a lot!
Wow, thanx man... saved my life...
Device.BeginInvokeOnMainThread (() => {
yourPicker.Focus ();
});
This is similar to WPF
@AngYiYang thank you
@AngYiYang
Device.BeginInvokeOnMainThread(() =>
{
if (yourPicker.IsFocused)
yourPicker.Unfocus();
});
Thanks
....
Could anyone figure out how to make it work in UWP?
picker.Focus()
does nothing in UWP, even on main thread...