1: using System;
2: using System.Windows;
3: using System.Windows.Controls;
4: using TimHeuer.Silverlight;
5:
6: namespace SilverlightApplication147
7: {
8: public partial class MainPage : UserControl
9: {
10: TranslatorClient _translator;
11:
12: public MainPage()
13: {
14: InitializeComponent();
15:
16: _translator = new TranslatorClient("YOUR_APP_ID");
17: _translator.TranslateCompleted += new EventHandler<TranslateCompletedEventArgs>(OnTranslateCompleted);
18: }
19:
20: void OnTranslateCompleted(object sender, TranslateCompletedEventArgs e)
21: {
22: Dispatcher.BeginInvoke(() =>
23: {
24: MessageBox.Show(e.TranslatedText);
25: });
26: }
27:
28: private void TranslateButton_Click(object sender, RoutedEventArgs e)
29: {
30: // if you needed to detect the source language first you would run DetectAsync to get the Source Language
31: // below is an example of TranslateAsync("Du bist wie eine Blume", "de", "en")
32: _translator.TranslateAsync(TextToTranslateTextBox.Text, SourceLanguageTextBox.Text, TargetLanguageTextBox.Text);
33: }
34: }
35: }