lxa85,
MainPage.cs:
Код:
![Выделить весь код](images/misc/selectcode.png)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using WP.StundentServiceReference;
namespace WP {
public partial class MainPage { // Конструктор
public MainPage() { InitializeComponent(); }
private void PhoneApplicationPageLoaded(object sender, RoutedEventArgs e)
{
var serviceClient = new StudentService1Client();
serviceClient.GetAllStudentsCompleted += ServiceClientGetAllStudentsCompleted;
serviceClient.GetAllStudentsAsync();
}
void ServiceClientGetAllStudentsCompleted(object sender, StundentServiceReference.GetAllStudentsCompletedEventArgs e)
{
if (e.Result != null)
{ ListBox1.ItemsSource = e.Result; }
}
private void navigateitem(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("/ItemPage.xaml", UriKind.Relative));
}
}
}
MainPage.xaml:
Код:
![Выделить весь код](images/misc/selectcode.png)
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="StudentDataTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Margin="10" Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="МОЕ ПРИЛОЖЕНИЕ"
Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="имя страницы" Margin="9,-7,0,0"
Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox ItemsSource="{Binding}"
ItemTemplate="{StaticResource StudentDataTemplate}"
Height="Auto"
Width="460"
Margin="10,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Name="ListBox1"/>
<Button Click="navigateitem"
Content="Button"
Height="72"
HorizontalAlignment="Left"
Margin="142,351,0,0"
Name="button1"
VerticalAlignment="Top"
Width="160" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
Таблица: Medicaments
Поля: Id, Name, Characters
Из кода XAML я выкинул ненужное(то, что вверху Visual Studio создает автоматически и закомментированный Application Bar)