我試圖使用folloiwng綁定一個簡單的列表視圖控制列表視圖不顯示名稱空間值8.1運行時
<ListView x:Name="listView" ItemsSource="{Binding}">
<StackPanel Orientation="Horizontal" Width="292" Height="80">
<Border Height="60" Width="60" Margin="10,10,0,10">
<Image Source="/SampleImage.png" Stretch="UniformToFill"/>
</Border>
<StackPanel Orientation="Vertical" VerticalAlignment="Top" Margin="0,10,0,0">
<TextBlock Text="{Binding description}"
Margin="10,0,0,0" Width="180" Height="42"
TextTrimming="WordEllipsis" TextWrapping="Wrap" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding Title}"
Margin="10,2,0,0" Width="180" Height="14"
TextTrimming="WordEllipsis" HorizontalAlignment="Left"
FontSize="9" Opacity="0.49"/>
</StackPanel>
</StackPanel>
</ListView>
但其作爲原料,解析這樣 創建時,我引用我的列表中的某些原因;使用系統的 ; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel;使用System.Linq的 ; using System.Threading.Tasks;
namespace Curo.DataModel
{
public class curoLists : INotifyPropertyChanged
{
public curoLists()
{
}
public curoLists(String uniqueId, String title, String subtitle, String imagePath, String description, String content, string type)
{
this.UniqueId = uniqueId;
this.Title = title;
this.Subtitle = subtitle;
this.Description = description;
this.ImagePath = imagePath;
this.Content = content;
this.Type = type;
}
public curoLists(String uniqueId, String title, String subtitle, String imagePath, String description, String content, bool unread, Int32 status)
{
UniqueId = uniqueId;
Title = title;
Subtitle = subtitle;
Description = description;
ImagePath = imagePath;
Content = content;
Unread = unread;
Status = status;
}
private bool _unread;
private string _title;
public string UniqueId { get; private set; }
public string Title
{
get { return _title; }
set
{
_title = value;
NotifyPropertyChanged("Title");
}
}
public string Subtitle { get; private set; }
public string Description { get; private set; }
public string ImagePath { get; private set; }
public string Content { get; private set; }
public int Status { get; private set; }
public string Type { get; private set; }
public string ViewToUse { get; private set; }
public bool Unread
{
get { return _unread; }
set
{
_unread = value;
NotifyPropertyChanged("Unread");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public static async Task<curoLists> CreateFromParseObject(ParseObject parseObject)
{
return await Task.Run<curoLists>(() =>
{
var mlist = new curoLists();
mlist.Title = parseObject.ObjectId;
if (parseObject.ContainsKey("name"))
{
mlist.Title = (string)parseObject["name"];
}
if (parseObject.ContainsKey("description"))
{
mlist.Description = (string)parseObject["description"];
}
if (parseObject.ContainsKey("image"))
{
mlist.ImagePath = (string)parseObject["image"];
}
if (parseObject.ContainsKey("type"))
{
string mtype = (string)parseObject["type"];
if (mtype == "N")
{
mlist.Type = "Notes";
mlist.ViewToUse = "Notes.Xaml";
}
}
return mlist;
});
}
}
}
它不顯示請求的數據,而只是顯示下面的內容。我在填充以下mannor
List<curoLists> cLists;
public ClientsManage()
{
this.InitializeComponent();
PopulatelistAsync();
}
public async Task PopulatelistAsync()
{
try
{
curoListsDal _db = new curoListsDal();
cLists = await _db.GetListsAync();
listView.ItemsSource = cLists;
}
catch (Exception ex)
{
}
}
我的清單,但它只是顯示的名字空間,而不是數據Curo.DataModel.CuroLists。當我調試數據時,它確定了它們的正確拼寫,當我編譯時,它唯一抱怨的是我的構造函數,我沒有await命令,但不會使數據不會顯示它?
您是否嘗試過使用ObservableCollection而不是列表? –
tdmanutd