C# 绑定的可观察集合未显示在列表视图中
如果我使用C# 绑定的可观察集合未显示在列表视图中,c#,wpf,binding,C#,Wpf,Binding,如果我使用项目作为项目资源它正在工作,但是如果我使用排序的项目它不会显示在列表视图中 ObservableCollection<myModel> items = new ObservableCollection<myModel>(); ObservableCollection<myModel> sorted_items = new ObservableCollection<myModel>(); lv_items.ItemsSource =
项目
作为项目资源
它正在工作,但是如果我使用排序的项目
它不会显示在列表视图中
ObservableCollection<myModel> items = new ObservableCollection<myModel>();
ObservableCollection<myModel> sorted_items = new ObservableCollection<myModel>();
lv_items.ItemsSource = sorted_items;
items.Add(new myModel
{
ImageSource = myImage,
Name = item_name;
});
sorted_items = items;
for (int j = 0; j < sorted_items.Count; j++)
{
sorted_items.Move(sorted_items.Count - 1, j)
}
observetecollection items=新的observetecollection();
ObservableCollection sorted_items=新的ObservableCollection();
lv_items.ItemsSource=已排序的_项;
items.Add(新的myModel)
{
ImageSource=myImage,
名称=项目名称;
});
已排序的项目=项目;
对于(int j=0;j
我的蜘蛛感觉告诉我,你应该在分配任务后尝试移动lv\u项目。项目来源=已排序的\u项目
,或者在你的for
for (int j = 0; j < sorted_items.Count; j++)
{
sorted_items.Move(sorted_items.Count - 1, j)
}
lv_items.ItemsSource = sorted_items;
for(int j=0;j
此代码甚至不会编译,因为您在声明之前使用的是已排序的\u项。
我的错,我是用scratch编写的。不管怎样,thanks@BrianSanchez如果符合您的目的,请确保将其标记为已回答:)