Sunday, July 4, 2010

Currency Conversion Using Web Service

For this post I have used the web service which are free to use. I have used the currency conversion from one country currency to another country currency rate. Below is the screen shot of the example application. The GUI is very simple as you have to select from the conversion from currency and then select Conversion to currency and press the convert button.

In the application I have used the two combo Box for the selection of the currencies and one button to call the web service to convert the currency from From currency to To currency. What I have learn from this post is how to bind the selected item with the text box text property. Which I would like to share with you. Below is the code to bind the selected item from the combo box with the text block text property, the text blocks are placed at the title place to let you know about which currencies are selected.

<TextBlock Margin="4,0,0,0" VerticalAlignment="Center" Text="{Binding Path=SelectedItem.CurrencyName, ElementName=cboConversionFrom, Mode=OneWay}" TextWrapping="Wrap" Grid.Column="1" Foreground="{StaticResource CheckBoxBrush}" />

Here you can see that Text property of the text block, I have set the path of the to selectedItem.CurrencyName and the element name is cboConversionFrom. Every time the selectedItem from the cboConversionFrom change the text property is also changed.

To consume the asmx service I have create asmx service in my web project which will be consumed by the silverlight project. For the communication purpose the service should be running when you made web service call.You can download the source code from here
All and any comments / bugs / suggestions are welcomed!

No comments: