簡體   English   中英

通過Silverlight(wcf + linq)連接將數據保存在本地變量中

[英]Save data in local variable using by silverlight(wcf+linq) connection

幾天前開始在SilverLight編程,並且使用wcflinq將數據保存在本地變量數據庫中存在一些問題。 連接和數據結果正常。

public void load(){
    ServiceReference.ServiceClient serv=new ServiceReference.ServiceClient();
    serv.GetAssetListCompleted+=new EventHandler<ServiceReference1.GetAssetListCompletedArgs>(serv_GetAssetListCompleted);
    serv.GetAssetListAsync();
}

void serv_GetAssetList(object sender, ServiceReference.GetAssetListCompletedEventArgs e)
{
    datagrid1.ItemsSource=e.Result;
}

這段代碼正在運行,我的datagrid1正在用Xaml代碼中的element.(AutoGenerateColumns="True")填充。 但是我想將此數據網格保存到列表或其他內容中。 因為我想使用這些信息,例如局部變量。

嘗試了很多代碼,例如:

void serv_GetAssetList(object sender, ServiceReference.GetAssetListCompletedEventArgs e)
{
    var result_list=e.Result.toList();
}

要么

void serv_GetAssetList(object sender, ServiceReference.GetAssetListCompletedEventArgs e)
{
    string[] temp=new string[e.Result.Count];
    for (int i=0;i<e.Result.Count;i++)
    temp[i]=e.Result[i].Id;
}

但是沒有任何作用。 它們都顯示一個空變量。

嘗試這個:

    void serv_GetAssetList(object sender, ServiceReference.GetAssetListCompletedEventArgs e)
    {

   MessageBox.show(e.result.count);


    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM