使用WebService将SQL绑定到WP8时的Ling-to-Sql问题 [英] Ling-to-Sql issue when bind SQL to WP8 using WebService
问题描述
我刚刚尝试创建我的第一个WP8 application
,它将为Bind data from SQL Database
.我遵循了本教程,但只有black page appears
.
I have just tried to create my first WP8 application
which would Bind data from SQL Database
. I followed this tutorial but only black page appears
.
由于WP8工具中没有列表框,因此我使用LongListSelector
如下:
As there is no ListBox in WP8 tools I used LongListSelector
as following:
MainPage.xaml
MainPage.xaml
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="ToursDataTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="10" Text="{Binding name}"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="9*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<phone:LongListSelector
x:Name="MyLongListSelectors"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource ToursDataTemplate}"
/>
这是我的MainPage.xaml.cs
This is my MainPage.xaml.cs
using PhoneApp1.Resources;
using PhoneApp1.ToursServiceReference1;
namespace PhoneApp1
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
ToursServiceReference1.ToursService1Client serviceClient = new ToursServiceReference1.ToursService1Client();
serviceClient.GetAllKlientsCompleted += new EventHandler<ToursServiceReference1.GetAllKlientsCompletedEventArgs>(serviceClient_GetAllKlientsCompleted);
serviceClient.GetAllKlientsAsync();
}
private void serviceClient_GetAllKlientsCompleted(object sender, ToursServiceReference1.GetAllKlientsCompletedEventArgs e)
{
if (e.Result != null)
{
MyLongListSelectors.ItemsSource = e.Result;
}
}
如果我应该提供更多信息,请告诉我.希望不要接受低票,因为这是一个安静的低质量问题.
In case that I should provide more information please let me know. Hope not to receive down-votes as this is quiet low-quality question.
没有错误或类似的迹象.
There is no sign of error or anything similar.
感谢大家的宝贵时间.
推荐答案
您期望看到什么?
在serviceClient_GetAllKlientsCompleted
方法中您什么也没做.您的列表将始终为空,因为您没有提供任何要显示的数据
You are doing nothing inside serviceClient_GetAllKlientsCompleted
method. Your list will always be empty as you are not providing it any data to display
private void serviceClient_GetAllKlientsCompleted(object sender, ToursServiceReference1.GetAllKlientsCompletedEventArgs e)
{
if (e.Result != null)
{
//set the data context of list here
}
}
这篇关于使用WebService将SQL绑定到WP8时的Ling-to-Sql问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!