我试图使用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