我需要更新服务器上的数据。
GET
数据我能够GET
来自服务器的数据,但无法在文本框中显示
我的XAML代码:
<Grid x:Name="ContentPanel" Margin="12,157,12,4" Grid.RowSpan="2">
<TextBlock HorizontalAlignment="Left" Height="30" Margin="20,67,0,0" TextWrapping="Wrap" Text="Name" VerticalAlignment="Top" Width="65"/>
<TextBox x:Name="txt_name" HorizontalAlignment="Left" Height="73" Margin="121,42,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="315" BorderThickness="0" InputScope="PersonalFullName"/>
</Grid>
我在网页加载时从服务器检索数据的代码:
private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
String OrganizationResult;
if (NavigationContext.QueryString.ContainsKey("selectedItem"))
{
OrganizationResult = NavigationContext.QueryString["selectedItem"];
string[] content = OrganizationResult.Split(',');
string value = content[0];
String id = value.Replace("{ id = ", "");
Organization[] org;
org = await client.searchOrganizationdetails(id);
if (org != null)
{
var query = from c in org
select new
{
// Need to display the contents in textbox
// Eg:txt_name.Text=c.name
};
}
}
}
我的示例JSON数据:
答案 0 :(得分:0)
是否需要在LINQ查询内部?我认为你不能这样做......
答案 1 :(得分:0)
如果您需要绑定到列表
假设您的集合属于
类型public class Organization
{
public string Name { get; set; }
public string Address { get; set; }
}
你的xaml应该是
<ListBox x:Name="lstOrganisations">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" />
<TextBox Text="{Binding Address}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
与
绑定lstOrganisations.ItemSource = org;