我想将可观察集合中的值从第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();
}
如何将其分配给全球?
答案 0 :(得分:0)
不确定FindOrderCompletedEventArgs是什么,但你应该做
void proxy_FindOrderCompleted(object sender, FindOrderCompletedEventArgs e)
{
Orders = new ObservableCollection<Order>(e.Result);
listBox1.ItemsSource = Orders;
}