我需要一些关于Xamarin Forms项目的帮助我想实现一个简单的选择器Xaml绑定到3个标签,当我从选择器中选择一个值时,标签将自动填充.(数据来自SQLite).这是我有的:
<Picker x:Name="ListJobs" Title="Select Job" ItemsSource="{Binding options}" ItemDisplayBinding="{Binding JobNo}" SelectedItem="{Binding SelectedJobs}"/>
<Label Text="{Binding JobsId}" IsVisible="True" x:Name="TxtId"/>
<Label Text="{Binding name}" IsVisible="True" x:Name="TxtName"/>
<Label Text="{Binding location}" IsVisible="True" x:Name="TxtLoc"/>
Run Code Online (Sandbox Code Playgroud)
模型
public class Jobs
{
public string JobsId {get;set;}
public string name {get;set;}
public string location {get;set;}
public Jobs(){}
}
Run Code Online (Sandbox Code Playgroud)
代码背后:
protected override OnAppearing()
{
jobsInfo = (List<Jobs>) GetJob();
foreach (var item in jobsInfo)
{
Jobs options = new Jobs
{
JobsId = item.JobsId,
name = item.name,
location = item.location
};
BindingContext = …Run Code Online (Sandbox Code Playgroud)