C# 4.0 windows phone中的列表选取器问题 List List=新列表(); 列表=(来自文档子体(“行”)中的查询) 选择新项目 { Id=Convert.ToInt64(query.Element(“Id”).Value), Name=query.Element(“Name”).Value, title=query.Element(“title”).Value }).ToList(); listPicker1.DataContext=列表;
是否可以在windows phone列表选取器中默认显示“Select”,并且每当我选择列表选取器项目时,都应显示该项目 以下是我目前掌握的代码:C# 4.0 windows phone中的列表选取器问题 List List=新列表(); 列表=(来自文档子体(“行”)中的查询) 选择新项目 { Id=Convert.ToInt64(query.Element(“Id”).Value), Name=query.Element(“Name”).Value, title=query.Element(“title”).Value }).ToList(); listPicker1.DataContext=列表;,c#-4.0,windows-phone,listpicker,C# 4.0,Windows Phone,Listpicker,是否可以在windows phone列表选取器中默认显示“Select”,并且每当我选择列表选取器项目时,都应显示该项目 以下是我目前掌握的代码: List<Items> list = new List<Items>(); list = (from query in doc.Descendants("row") select new Items {
List<Items> list = new List<Items>();
list = (from query in doc.Descendants("row")
select new Items
{
Id = Convert.ToInt64(query.Element("Id").Value),
Name = query.Element("Name").Value,
title = query.Element("title").Value
}).ToList();
listPicker1.DataContext = list;
要进行此操作,请添加一个名为“选择”的项目并将其设置为默认值 感谢bro的回复,但我的项目源来自类,而不是手动,它与“{Binding}”绑定,无论源是什么,从类中获取它并管理对象中的状态。我的列表选择器项目作为web服务响应出现,因此如何解决?谢谢将其添加到您的Web服务中!我不能,因为我没有创建web服务,我只是调用这个方法,它是用java创建的。
<toolkit:ListPicker ItemsSource="{Binding}" x:Name="listPicker1" FullModeHeader="Employee" SelectionChanged="ListPicker1_SelectionChanged" BorderThickness="0" Margin="130,-45,144,160" SelectedItem="{Binding}" SelectionMode="Single" ExpansionMode="FullScreenOnly" Header="" CacheMode="BitmapCache" Height="55" Background="White">
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" TextWrapping="Wrap" FontSize="22" Width="200" Height="50" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Center" Foreground="Blue"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name}" Margin="10" FontSize="24" TextWrapping="Wrap" Foreground="Black" Width="440"/>
<TextBlock Text="{Binding title}" FontSize="20" TextWrapping="Wrap" Foreground="Black" Width="440"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>