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
.
As there is no ListBox in WP8 tools I used LongListSelector
as following:
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}"
/>
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.
Thank you everyone for your time.