Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 绑定的可观察集合未显示在列表视图中_C#_Wpf_Binding - Fatal编程技术网

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如果符合您的目的,请确保将其标记为已回答:)