0

我想将可观察集合中的值从第 1 页传递到第 2 页。如何使用全局变量传递它?

public pg1()
{    
    InitializeComponent();
    proxy.FindOrderCompleted += new EventHandler<FindOrderCompletedEventArgs>(proxy_FindOrderCompleted);
    proxy.FindOrderAsync(custemail);
}

void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
    listBox1.ItemsSource = e.Result;
    ObservableCollection<Order> Orders = this.listBox1.ItemsSource as ObservableCollection<Order>;
}

在 xmal 将其分配为

public ObservableCollection <Order> Orders  
{ 
    get; set; 
}

public List<Order> FindOrder(string custemail, string orderstatus)
        {
            var findorder = from r in order.Orders where (r.CustEmail  == custemail && r.OrderStatus == orderstatus ) select r;
            return findorder.ToList();
        }

如何将其分配给全局?

4

1 回答 1

0

不确定 FindOrderCompletedEventArgs 是什么,但你应该这样做

void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
    Orders = new ObservableCollection<Order>(e.Result);
    listBox1.ItemsSource = Orders;
}
于 2012-06-20T23:27:58.173 回答