2016-06-09 3 views
0

특정 웹 사이트에서받은 개체를 바인딩하는 데 문제가 있습니다. 필요한 모델을 만들고 필요한 정보가 정확한지 확인 했으므로 내 정보를 얻고 있습니다. 문제는 그 것입니다. 특정 정보가있는 격자를 만들려고하고 있는데 바인딩 기능을 사용하여 처리 할 수 ​​없다면 아무것도 표시되지 않는 것 같습니다. 컨텍스트 : Xamarin을 사용하여 모바일 응용 프로그램을 만들고 있는데 특정 정보를 받기 위해 REST를 사용하고 있습니다.바인딩 개체의 문제

Transactions.TransactionList transactionmade = JsonConvert.DeserializeObject<Transactions.TransactionList>(result); 

여기에 문제

,692,626 정보를 수신하지하는 데 사용 // 나는 간단한 foreach 문을 수행 할 경우

7,273,210 또한 문제는, 내가, 모두 2 층과 3 레벨 정보를하지 접근 할 필요가 내가 바인딩에 여기

foreach (var item in transactionmade.transactions) 
    { 
    Debug.WriteLine("id=={0} .. holder=={1} .. value=={2}", 
       item.id, item.counterparty.holder.name, item.details.value.amount); 
    } 

// 문제를 필요로하는 정보를 보여줍니다 코드는 여기에있다하지만 난이 내가

idLabelholder.SetBinding(Label.TextProperty, "account: {id}"); 

dateofCompletionLabel.SetBinding(Label.TextProperty, "details: {completed }; 

amountLabel.SetBinding(Label.TextProperty, "details: {value: {amount }}"); 

balanceLabel.SetBinding(Label.TextProperty, "details: {new_balance: {amount }}");  

이 모델이

public class Holder 
    { 
     public string name { get; set; } 
     public bool is_alias { get; set; } 
    } 

    public class Bank 
    { 
     public string national_identifier { get; set; } 
     public string name { get; set; } 
    } 

    public class Account 
    { 
     public string id { get; set; } 
     public List<Holder> holders { get; set; } 
     public string number { get; set; } 
     public object kind { get; set; } 
     public object IBAN { get; set; } 
     public object swift_bic { get; set; } 
     public Bank bank { get; set; } 
    } 

    public class Holder2 
    { 
     public string name { get; set; } 
    } 

    public class Bank2 
    { 
     public string national_identifier { get; set; } 
     public string name { get; set; } 
    } 

    public class Counterparty 
    { 
     public string id { get; set; } 
     public Holder2 holder { get; set; } 
     public string number { get; set; } 
     public object kind { get; set; } 
     public object IBAN { get; set; } 
     public object swift_bic { get; set; } 
     public Bank2 bank { get; set; } 
    } 

    public class NewBalance 
    { 
     public string currency { get; set; } 
     public string amount { get; set; } 
    } 

    public class Value 
    { 
     public string currency { get; set; } 
     public string amount { get; set; } 
    } 

    public class Details 
    { 
     public string type { get; set; } 
     public string description { get; set; } 
     public string posted { get; set; } 
     public string completed { get; set; } 
     public NewBalance new_balance { get; set; } 
     public Value value { get; set; } 
    } 

    public class Transaction 
    { 
     public string id { get; set; } 
     public Account account { get; set; } 
     public Counterparty counterparty { get; set; } 
     public Details details { get; set; } 
    } 

    public class TransactionList 
    { 
     public List<Transaction> transactions { get; set; } 
    } 
을 사용하는 것입니다 만든 validtemplate의 fuction를 내부에 이해하기 쉬운 생각

이상 여기가 정보의 간단한 예제가 표시되는 정보

이제
App.Models.Transactions+Transaction 

내가이 내가 만들어 낸 그 목록보기의 응답 것을 알고 있지만, 어떻게되어

{ 
"transactions": [ 
{ 
    "id": "065bf1e2-c39c-49b9-98ca-2604db647284", 
    "account": { 
    "id": "somebodymillionaire", 
    "holders": [ 
     { 
     "name": "somebody1", 
     "is_alias": false 
     } 
    ], 
    "number": "8585757136", 
    "kind": null, 
    "IBAN": null, 
    "swift_bic": null, 
    "bank": { 
     "national_identifier": "rbs", 
     "name": "The Royal Bank of Scotland" 
    } 
    }, 
    "counterparty": { 
    "id": "f39f20a3-15ff-475e-b654-d377df58ee5d", 
    "holder": { 
     "name": "somebodycounter" 
    }, 
    "number": "8964202115", 
    "kind": null, 
    "IBAN": null, 
    "swift_bic": null, 
    "bank": { 
     "national_identifier": "rbs", 
     "name": "The Royal Bank of Scotland" 
    } 
    }, 
    "details": { 
    "type": "sandbox-payment", 
    "description": "im a millionaire", 
    "posted": "2016-06-07T20:36:40Z", 
    "completed": "2016-06-07T20:36:40Z", 
    "new_balance": { 
     "currency": "EUR", 
     "amount": "9449.47" 
    }, 
    "value": { 
     "currency": "EUR", 
     "amount": "-550.53" 
    } 
    } 
}]} 

을받은 것입니다 해당 목록의 다른 계층에 대한 정보 요청을 표시하기 위해 만든 바인딩 레이블을 표시 할 수 있습니까? 대부분의 예제는 계층 1 json 목록이므로 다른 계층의 정보는 어떻게 얻을 수 있습니까?

내가 뭘 잘못하고 있니? 고맙습니다. 고급 :

답변

0

현재 양식이 변수를 고정 텍스트와 결합하는 바인딩을 지원한다고 생각하지 않습니다.

idLabelholder.SetBinding(Label.TextProperty, "id"); 

dateofCompletionLabel.SetBinding(Label.TextProperty, "details.completed"); 

amountLabel.SetBinding(Label.TextProperty, "details.value.amount"); 

balanceLabel.SetBinding(Label.TextProperty, "details.new_balance.amount"); 
+0

빠른 응답을 보내 주신 Jason에게 감사하지만 여전히 작동하지 않는 것 같습니다. 바인딩을 사용하는 대신이 솔루션에 대한 또 다른 접근 방법이 있습니까? –

관련 문제