xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

Binding Selected record to Picker #6445

Closed arvindrajachourasiya closed 5 years ago

arvindrajachourasiya commented 5 years ago

Description

On ViewModel loading I am binding default record to Picker. When initializing Picker using newkeyword Picker selection isn't working

public override void OnNavigatedTo(INavigationParameters parameters)
{
    base.OnNavigatedTo(parameters);
    var objL = parameters.GetValue<LeaveManagement>("LeaveItem");
    SelectedLeaveType = new SpinnerBind { Value = objL.LeaveTypeId, Name = objL.LeaveTypeCD };
    //SelectedLeaveType = LeaveType.Where(i => i.Value == objL.LeaveTypeId).FirstOrDefault();           
}

But when getting selected SelectedLeaveTypefrom Source data it is working See code below. Why so?

public override void OnNavigatedTo(INavigationParameters parameters)
{
    base.OnNavigatedTo(parameters);
    var objL = parameters.GetValue<LeaveManagement>("LeaveItem");   
    SelectedLeaveType = LeaveType.Where(i => i.Value == objL.LeaveTypeId).FirstOrDefault();           
}

Steps to Reproduce

Expected Behavior

Actual Behavior

Basic Information

Screenshots

Reproduction Link

samhouts commented 5 years ago

@arvindrajachourasiya Can you please attach a small project that demonstrates this issue? Thanks!

samhouts commented 5 years ago

@arvindrajachourasiya Since we haven't heard from you in more than 30 days, we hope this issue is no longer affecting you. If it is, please reopen this issue and provide the requested information so that we can look into it further. Thank you!