I'm working in window phone. I have to bind data in to grid in windows phone.
I got results from 开发者_JAVA百科web service such as name , address, id, category. I need When I click the name, it displays the all details. So, how can I do to display those details?
As Mike says, look at the code created as part of a new DataBound application.
Also, rather than displaying data in a grid, it's probably better to display data vertically in a column:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<TextBlock Text="Name" Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Text="{}Binding Name}" Margin="20,0,0,0" />
<TextBlock Text="ID" Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Text="{Binding ID}" Margin="20,0,0,0" />
<TextBlock Text="City" Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Text="{Binding City}" Margin="20,0,0,0" />
<TextBlock Text="Category" Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Text="{Binding Category}" Margin="20,0,0,0" />
<TextBlock Text="Others" Style="{StaticResource PhoneTextLargeStyle}" />
<TextBlock Text="{Binding Others}" Margin="20,0,0,0" TextWrapping="Wrap" />
</StackPanel>
</Grid>
And as a quick way to see what this might look like when populated:
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
Loaded += MainPage_Loaded;
}
void MainPage_Loaded(object sender, RoutedEventArgs e)
{
// This would really be the data returned from the web service
var sampleData = new WsData
{
Name = "Girilas & Gandhi Nagar",
ID = "842",
City = "Bangalore",
Category = "Shopping Mall",
Others = "AC Types: central\n AC, Split AC Windows\nACWhirlpool:\nMicrowave Oven ..."
};
this.DataContext = sampleData;
}
}
public class WsData
{
public string Name { get; set; }
public string ID { get; set; }
public string City { get; set; }
public string Category { get; set; }
public string Others { get; set; }
}
You might like to have a look at making a project using the Databound Project template, as it produces a result very similar to what you describe that you can use as a starting point.
精彩评论