This article will briefly describe how to use WebRequest for data submission and acquisition in Silverlight 2.
Simple example
In this article, we still use the example of the Silverlight 2 series (12) in step by step: The WebClient used in data and communication, except to make minor changes, submit book Number data using WebRequest, and return price information based on the book number. The results of the final run are shown below:
To write an interface layout, the XAML is as follows:
<grid background= "#46461F" >
<Grid.RowDefinitions>
<rowdefinition height= "></RowDefinition>"
<rowdefinition height= "*" ></RowDefinition>
<rowdefinition height= "></RowDefinition>"
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<border grid.row= "0" grid.column= "0" cornerradius= "15"
Width= "height=" "36"
margin= "0 0 0" horizontalalignment= "left" >
<textblock text= "book list" foreground= "white"
Horizontalalignment= "left" verticalalignment= "Center"
margin= "0 0 0" ></TextBlock>
</Border>
<listbox x:name= "Books" grid.row= "1" margin= "40 10 10 10"
selectionchanged= "Books_selectionchanged" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<textblock text= "{Binding Name}" height= "></TextBlock>"
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<border grid.row= "2" grid.column= "0" cornerradius= "15"
Width= "height=" background= "Orange"
margin= "0 0 0" horizontalalignment= "left" >
<textblock x:name= "Lblprice" text= "Price:" foreground= "white"
Horizontalalignment= "left" verticalalignment= "Center"
margin= "0 0 0" ></TextBlock>
</Border>
</Grid>