-1

我很难理解 Silverlight 如何使用来自 Web 服务的异步响应。我已经宣布——

public partial class Users : Page
{
    public string PID;

然后使用-

 if
 {
 WebService.Service1SoapClient client = new WebService.Service1SoapClient();
 string profile = System.Convert.ToString(((ListBoxItem)listBox1.SelectedItem).Content);
 client.pidReturnCompleted += new EventHandler<pidReturnCompletedEventArgs>(client_pidReturnCompleted);
 client.pidReturnAsync(USERID, profile);
 }
 Else
 {

 KeyWords keywords = new KeyWords();

 keywords.textBox3.Text = PID;
 keywords.Show();

其中PID-

void client_pidReturnCompleted(object sender, pidReturnCompletedEventArgs e)
    {
        PID = e.Result;
    }

然后我需要在Initialise Component“关键字”子窗口的部分中使用此 PID,但是当窗口加载时,它没有及时获取 textBox.Text(PID 值),并说它为空。如何在 Initialise Component 阶段使用 PID?所以在关键字窗口中 -

public KeyWords()
    {
        InitializeComponent();

        this.Loaded += new RoutedEventHandler(KeyWords_Loaded);

        WebService.Service1SoapClient client = new WebService.Service1SoapClient();
        client.userKeywordsCompleted += new EventHandler<userKeywordsCompletedEventArgs>(client_userKeywordsCompleted);
        client.userKeywordsAsync(PID);

    }

在哪里-Public Int PID = textBox3.Text //this is where the value from the previous window is passed in.

4

1 回答 1

0

我通过创建一个Keywords_Loaded void 对其进行排序。然后我就可以使用从以前的表单传入的值。

于 2012-05-09T15:07:00.010 回答