我刚刚尝试创建我的第WP8 application
一个Bind data from SQL Database
。我遵循了本教程,但仅black page appears
.
由于 WP8 工具中没有 ListBox,我使用LongListSelector
如下:
主页.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
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;
}
}
如果我应该提供更多信息,请告诉我。希望不要收到反对票,因为这是一个安静的低质量问题。
没有错误或类似的迹象。
谢谢大家的时间。