C# LongListSelector无法更改ItemsSource

C# LongListSelector无法更改ItemsSource,c#,windows-phone-7,itemssource,longlistselector,C#,Windows Phone 7,Itemssource,Longlistselector,我似乎无法更改LongListSelector中的ItemsSource。在做了一些研究之后,LongListSelector似乎忽略了ItemsSource中的任何更改。我说的对吗 如果是,是否有解决办法 这就是我想做的。我可以选择按国家或城市对城市列表进行排序。大概是这样的: var groupByCountry = from City in App.ViewModelCity.Items group city by city.

我似乎无法更改LongListSelector中的ItemsSource。在做了一些研究之后,LongListSelector似乎忽略了ItemsSource中的任何更改。我说的对吗 如果是,是否有解决办法

这就是我想做的。我可以选择按国家或城市对城市列表进行排序。大概是这样的:

var groupByCountry = from City in App.ViewModelCity.Items
                                group city by city.GroupByCountry into c
                                orderby c.Key
                                select new Group<Currency>(c.Key, c);

var groupByCity = from City in App.ViewModelCity.Items
                                group city by city.GroupByCity into c
                                orderby c.Key
                                select new Group<City>(c.Key, c);
var groupByCountry=来自App.ViewModelCity.Items中的城市
按城市分组。按国家分组到c中
orderby c.Key
选择新组(c键,c);
var groupByCity=来自App.ViewModelCity.Items中的城市
按城市分组。按城市分组到c
orderby c.Key
选择新组(c键,c);
所以基本上两者是相同的,只是分组不同。我的想法是简单地将ItemsSource更改为groupByCountrygroupByCity,具体取决于用户的选择。不幸的是,更改ItemsSource没有效果。它根本不会更新。仅当应用程序重新启动(存储首选源)时,LongListSelector才会更新


那么有没有办法强制LongListSelector更新ItemsSource?如果不是,什么是一个好的解决方法?

我在WP7中开发,在实际分配之前,我将ItemSource设置为null,以便UI将更新为新的ItemSource

LongListSelectorA.ItemsSource = null;
Binding b;
b = new Binding("CollectionInViewModel");
LongListSelectorA.SetBinding(LongListSelector.ItemsSourceProperty, b);
试试看,祝你好运。:)

试着把它写成(来自…)城市;也许延迟执行是这里的问题。这似乎是解决办法