Announcement

All important changes of my site and my blog will be announced here.

Computer security

This is my hobby. I spend my freetime for it. I am not professional in this area. But I like it very much.

Everything Else

Which doesn’t belong to other categories will land here. It maybe about my daily life, entertainment, music, game … or something like that

Programming

This is my job. That means everyday I must sit before the monitor. Tip something, be annoyed by bugs,… but I simply like it.

Tutorial

When I found something interesting, I would like to share it to everyone. That is the reason for this category comes.

Home » Programming

Windows Phone – Use REST WCF Service

Sunday, 28 March 2010No Comment

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 http://hintdesk.com/wcf-silverlight-access-wcf-rest-services-with-silverlight/ . To start with the development in Windows Phone 7 you need to download set of development tools here http://www.microsoft.com/downloads/details.aspx?FamilyID=2338b5d1-79d8-46af-b828-380b0f854203&displaylang=en . 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">
	<ListBox.ItemTemplate>
		<DataTemplate>
			<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>
			</StackPanel>
		</DataTemplate>
	</ListBox.ItemTemplate>
</ListBox>

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

http://www.microsoft.com/downloads/details.aspx?FamilyID=2338b5d1-79d8-46af-b828-380b0f854203&displaylang=en

- Expression Blend 4 Beta

http://www.microsoft.com/downloads/details.aspx?FamilyID=6f014e07-0053-4aca-84a7-cd82f9aa989f&displaylang=en

- Expression Blend Add-in Preview for Windows Phone

http://www.microsoft.com/downloads/details.aspx?FamilyID=47f5c718-9dec-4557-9687-619c0fdd3d4f&displaylang=en

- Expression Blend SDK Preview for Windows Phone

http://www.microsoft.com/downloads/details.aspx?FamilyID=86370108-4c14-42ee-8855-226e5dd9b85b&displaylang=en

My strongly recommended books to read. Choose one and enjoy yourself.

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.