簡體   English   中英

在Xamarin.forms中無法在XAML頁面上看到綁定

[英]Unable to see Bindings on XAML page in Xamarin.forms

我有一個項目未在XAML頁面上顯示綁定。

我的RootObject

public class Notification
    {
        [JsonProperty("posts")]
        public Dictionary<string, List<Post>> posts { get; set; }
    }

    public class Post
    {
        [JsonProperty("title")]
        public string title { get; set; }

        [JsonProperty("image_url")]
        public Uri imageUrl { get; set; }

        [JsonProperty("message")]
        public string message { get; set; }

        [JsonProperty("time")]
        public string time { get; set; }
    }

我的服務班級(后面的代碼)

var notification = JsonConvert.DeserializeObject<Notification>(apiContent);
                    List<Post> posts = new List<Post>();
                    if (notification?.posts != null)
                    {
                        foreach (var item in notification.posts.Values)
                        {
                            posts.AddRange(item);
                        }
                    }

我的XAML文件

<Label Text="{Binding title}" />
<Label Text="{Binding message}" />

當XAML頁面上的解析完成時,它不會顯示API所需的標題或消息。當我檢查調試器時,它會為每個帖子顯示一個鍵/值對,因此我知道它是從API獲取數據的。

任何幫助,將不勝感激,謝謝。

關閉IsGroupingEnabled ItemsSource的數據未分組,因此您不應告訴ListView它是。

要使用分組,請查看ListView文檔中的“ 分組”部分

暫無
暫無

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

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