142104kesd5kp4jii5zyet   
XAML:
<phone:PhoneApplicationPage

x:Class="WebCPServic.MainPage"

xmlns="HTTP://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="HTTP://schemas.microsoft.com/winfx/2006/xaml"

xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"

xmlns:d="HTTP://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="HTTP://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"

FontFamily="{StaticResource PhoneFontFamilyNormal}"

FontSize="{StaticResource PhoneFontSizeNormal}"

Foreground="{StaticResource PhoneForegroundBrush}"

SupportedOrientations="Portrait" Orientation="Portrait"

shell:SystemTray.IsVisible="True">



<!--LayoutRoot 是包含所有頁面內容的根網格-->

<Grid x:Name="LayoutRoot" Background="Transparent">

<Grid.RowDefinitions>

<RowDefinition Height="Auto"/>

<RowDefinition Height="*"/>

</Grid.RowDefinitions>



<!--TitlePanel 包含應用程式的名稱和頁標題-->

<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

<TextBlock x:Name="ApplicationTitle" Text="WP7開發者:dev.ruanman.net" Style="{StaticResource PhoneTextNormalStyle}"/>

<TextBlock x:Name="PageTitle" Text="中英文翻譯" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>

</StackPanel>



<!--ContentPanel - 在此处放置其他内容-->

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

<TextBlock Height="49" HorizontalAlignment="Left" Margin="12,66,0,0" Name="des" Text="请输入你需要查询的英文或中文" VerticalAlignment="Top" Width="284" />

<TextBox Height="72" HorizontalAlignment="Left" Margin="6,106,0,0" Name="No" Text="dev.ruanman.net" VerticalAlignment="Top" Width="415" />

<Button Content="查询" Height="72" HorizontalAlignment="Left" Margin="12,184,0,0" Name="search" VerticalAlignment="Top" Width="247" Click="search_Click" />

<TextBlock Height="auto" TextAlignment="Center" HorizontalAlignment="Center" Margin="6,510,0,0" Name="hugwp" Text="www.ruanman.net" VerticalAlignment="Top" Width="444" />

<ListBox Height="242" HorizontalAlignment="Left" Margin="9,262,0,0" Name="listBox1" VerticalAlignment="Top" Width="441" />

</Grid>

</Grid>



<!--演示 ApplicationBar 用法的示例代码-->

<!--<phone:PhoneApplicationPage.ApplicationBar>

<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">

<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="按钮 1"/>

<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="按钮 2"/>

<shell:ApplicationBar.MenuItems>

<shell:ApplicationBarMenuItem Text="菜单项 1"/>

<shell:ApplicationBarMenuItem Text="菜单项 2"/>

</shell:ApplicationBar.MenuItems>

</shell:ApplicationBar>

</phone:PhoneApplicationPage.ApplicationBar>-->



</phone:PhoneApplicationPage>


C#:
private void search_Click(object sender, RoutedEventArgs e)

{



//具現化一個web service代理的物件



EnglishChineseReference.EnglishChineseSoapClient proxy = new EnglishChineseReference.EnglishChineseSoapClient();



//getMobileCodeInfo方法調用結束之後 觸發的事件



proxy.TranslatorStringCompleted += new EventHandler<EnglishChineseReference.TranslatorStringCompletedEventArgs>(proxy_GetIcpInfoByDomainCompleted);

//將調用資訊包括方法名和參數加入到soap消息中通過HTTP傳送給web service服務端



//這裡對應的是調用了web service的getMobileCodeInfo方法



proxy.TranslatorStringAsync(No.Text, "");



}



void proxy_GetIcpInfoByDomainCompleted(object sender, EnglishChineseReference.TranslatorStringCompletedEventArgs e)

{



if (e.Error == null)

{

try

{

this.listBox1.ItemsSource = e.Result;



}

catch (Exception)

{



MessageBox.Show("網路出現問題,或者是手機號碼錯誤");

}

}

else

{

MessageBox.Show("網路出現問題,或者是手機號碼錯誤");

}

}

 

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()