[英]Get Value for selected Item in ListPicker Windows Phone 8.1 Silverlight
I my Webserver ai have a method which return a list of properties: 我的Web服务器有一个返回属性列表的方法:
public class ListaProfessor
{
public String Nome { get; set; }
public String Curso { get; set; }
public String Periodo { get; set; }
public String Semestre { get; set; }
public String Turno { get; set; }
public String Data { get; set; }
}
And in my windows phone project i have 4 ListPicker's! 在我的Windows Phone项目中,我有4个ListPicker! each list picker has to receive 4 of the props that i created in my webserver.
每个列表选择器必须接收我在Web服务器中创建的4个道具。
<toolkit:ListPicker x:Name="CursoLista" Header="Curso" ItemsSource="{Binding}" SelectionChanged="CursoLista_SelectionChanged">
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel>
<toolkit:ListPickerItem Content="{Binding Curso}"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
</toolkit:ListPicker>
And in my Cs file: 在我的Cs文件中:
CursoLista.ItemsSource = e.Result;
as you can see i'm using Binding Curso
to select just a list of strings from my database,and i succeed. 如您所见,我正在使用
Binding Curso
从数据库中选择一个字符串列表,我成功了。
Those are my 4 ListPicker,and i want to select just the Name that will be Bind inside of ListPicker,knowing the e.Result
come with all props,and i just want to select One! 这些是我的4个ListPicker,我只想选择将要绑定到ListPicker内的名称,就知道
e.Result
附带了所有道具,我只想选择一个!
如果您不使用MVVM方法,则可以执行以下操作:
var content = ((ListPickerItem)CursoLista.SelectedItem).Content;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.