xamarin - Picker item source binding from view model -
i trying bind values picker model in view model,there getting path of model instead of values.
<picker x:name="locationpicker" title="location" heightrequest="40" horizontaloptions="fillandexpand" verticaloptions="fillandexpand" selecteditem="{binding location}" itemssource="{binding maintainroomtypes}"/>
here view model code:
if (jobdetailsforfitter != null) { windowdetails = new windowdetailsmodel { windows = jobdetailsforfitter.windows, locations = jobdetailsforfitter.locations, roomtypes = jobdetailsforfitter.roomtypes, addfiles = jobdetailsforfitter.addfiles }; locations = jobdetailsforfitter.locations; maintainroomtypes = jobdetailsforfitter.roomtypes; await fitterservice.instance.loadjobdetailstolocalstore(jobdetailsforfitter, selectedjob?.id ?? 0); }
how bind itemsource list.
public list<room> locations { get; set; } public list<roomtypemodel> roomtypes { get; set; }
you have define itemdisplaybinding
property picker
.
for eg:
public class room { public string roomnumber { private set; get; } public string roomname { private set; get; } }
and want display roomname in picker
<picker itemssource="{binding room}" itemdisplaybinding="{binding roomname}"/>
hope solve problem.
Comments
Post a Comment