Windows Phone – Use REST WCF Service

Today when I play around with development in Windows Phone 7. I would like to check if I can access WCF REST Service which I discussed before in this post . To start with the development in Windows Phone 7 you need to download set of development tools here . This set contains of
– Visual Studio 2010 Express for Windows Phone CTP
– Windows Phone Emulator CTP
– Silverlight for Windows Phone CTP
– XNA 4.0 Game Studio CTP
This packet is about 350 MB and can be installed parallel with Visual Studio 2008 SP1 and .Net Framework 3.5. When I try to move the example of the old post to Windows Phone 7, I think it must be very simple because the old example bases on Silverlight and Windows Phone 7 uses Silverlight as its default template and I am right. During the moving, I just need to copy and paste the code behind without needing to change anything. However some of components in normal Silverlight are not available, for example Label and DataGrid. The label can be easily replaced by a TextBlock but we need more work to make a control to replace DataGrid. I make a snapshot of available controls in image below

I decide to use ListBox to replace DataGrid and edit the ItemTemplate of ListBox so that I can show all information of data object

<ListBox ItemsSource="{Binding}" x:Name="dgStudents" Margin="10,60,6,228">
			<StackPanel Orientation="Horizontal">
				<TextBlock Text="{Binding StudentID}" Margin="0,0,0,0"></TextBlock>
				<TextBlock Text="{Binding Chair}" Margin="40,0,0,0"></TextBlock>
				<TextBlock Text="{Binding AverageNote}" Margin="40,0,0,0"></TextBlock>
				<TextBlock Text="{Binding StudentName}" Margin="40,0,0,0"></TextBlock>

The rest of code is completely same as old example. Just need to adjust the GUI so that it fits the screen of Windows Phone 7.

You can see that I try to size the controls as small as possible and leave the area near bottom blank as much as possible because when I try to input data, the keyboard will pop up from the bottom and cover our controls. The complete source code of this example you can download here “WCF REST and Windows Phone 7“.

The complete tool set for developing with Windows Phone is list below. Enjoy programming
– Windows Phone Developer Tools
– Expression Blend 4 Beta
– Expression Blend Add-in Preview for Windows Phone
– Expression Blend SDK Preview for Windows Phone

Leave a comment

Your email address will not be published. Required fields are marked *