当我尝试将我的数据库信息连接到我的pin.Setbinding / Bindingcontext

时间:2016-03-28 04:02:17

标签: c# xamarin xamarin.forms

foreach (var currentItem in getInfo["results"]) {

            theName = currentItem ["name"].ToString ();

            var pin = new Pin ();
            pin.Label = "test";
            pin.Adress = "test2";
            pin.SetBinding (Label.TextProperty, new Binding (theName)); 
            pin.BindingContext = theName;
            //this (setbinding, bindingcontext) gives me the error, if I add the value from the DB (theName) on my pin.Label instead it works fine. So the problem is when i am doing this setbinding/bindingcontext thing here.

}

我得到了“theName”的值,这是我日志中的一个字符串,但是当我尝试将它绑定到setbinding / bindingcontext时崩溃了。错误说:“路径包含empy部分”。如果我把它绑定到我的pin.Adress或pin.Adress它工作正常。如果我在我的setbinding / bindingcontext上键入“test”,它也可以。所以我对错误感到困惑。

这是我访问我的数据(它的工作原理):

static public async Task<JObject> getInfo ()
{
    var httpClientRequest = new HttpClient ();

    var result = await httpClientRequest.GetAsync ("localhost");

    var resultString = await result.Content.ReadAsStringAsync ();

    var jsonResult = JObject.Parse (resultString);

    return jsonResult;

} 

0 个答案:

没有答案