在子窗口中使用响应值 [英] Use response value in child window

查看:37
本文介绍了在子窗口中使用响应值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解 Silverlight 如何使用来自 Web 服务的异步响应.我已经声明-

I am having difficulty getting to grips with how Silverlight uses asynchronous responses from a web service. I have declared-

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 值),并说它是空的.如何在初始化组件阶段使用 PID?所以在关键字窗口-

I then need to use this PID in the Initialise Component section of the Keywords child window, however when the window loads, it does not get the textBox.Text (the PID value) in time, and says it is null. How can I use the PID in the Initialise Component stage? So in the Keywords window-

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);

    }

Where- Public Int PID = textBox3.Text//这是前一个窗口的值传入的地方.

推荐答案

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

I sorted it by creating a Keywords_Loaded void. I was then able to use the values passed in from the previous form.

这篇关于在子窗口中使用响应值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆