Forum Xamarin.Forms

Sometimes pickers and entry fields visibility problem

HarshitaHarshita INMember ✭✭✭✭
edited February 2018 in Xamarin.Forms

I have an content page that contain a registration form,and this page controled by a configuration page(visible,editable,disable). so when this page load the configuration data,few times disable option not woking.and in that case form fields loaded incorrectly.

if (!string.IsNullOrEmpty(PriorityValue))
                    {
                        if (PriorityValue == "Editable")
                        {
                            Priority.IsEnabled = true;
                            PriorityLbl.IsVisible = true;
                        }
                        else if (PriorityValue == "ReadOnly")
                        {
                            Priority.IsEnabled = false;
                            PriorityLbl.IsVisible = true;
                        }
                        else
                        {
                            Priority.IsVisible = false;
                            PriorityLbl.IsVisible = false;
                        }
                    }

after put this code under:

 Device.BeginInvokeOnMainThread(() =>
                    {
                Priority.IsEnabled = true;
                                PriorityLbl.IsVisible = true;
            });

Then it will works fine.

so is it a good solution for controling visibility for each fields?

Sign In or Register to comment.