C# 带定位器的Mvvm绑定到JumpList LongList

C# 带定位器的Mvvm绑定到JumpList LongList,c#,windows-phone-8,mvvm,longlistselector,C#,Windows Phone 8,Mvvm,Longlistselector,好吧,让我们看看。。。 我有一个ViewModel类,它有一个从存储器中检索数据的生成器,另一个向Internet请求数据的方法,它有一个保护程序notifypropertychange方法和locator方法。 但问题是如何将它绑定到jumplistbox,因为我使用定位器绑定时,无法将其作为一个组进行处理,以获取标题并对其进行排序 公共类FriendLocator { 私人朋友; 公共FriendLocator() { mainVMFriends=newLazy(()=>newViewMod

好吧,让我们看看。。。 我有一个ViewModel类,它有一个从存储器中检索数据的生成器,另一个向Internet请求数据的方法,它有一个保护程序notifypropertychange方法和locator方法。 但问题是如何将它绑定到jumplistbox,因为我使用定位器绑定时,无法将其作为一个组进行处理,以获取标题并对其进行排序

公共类FriendLocator
{
私人朋友;
公共FriendLocator()
{
mainVMFriends=newLazy(()=>newViewModelFriends());
}
公共视图模型好友MainVMFriends
{
收到
{
返回mainVMFriends.Value;
}
}
}
公共类VMFriendsBase:INotifyPropertyChanged
{
公共VMFriendsBase()
{ }
公共事件属性更改事件处理程序属性更改;
public void RaisePropertyChanged(字符串propertyName)
{
if(this.PropertyChanged!=null)
{
this.PropertyChanged(this,newpropertychangedventargs(propertyName));
}
}
}
公共类ViewModelFriends:VMFriendsBase
{
IsolatedStorageSettings设置=IsolatedStorageSettings.ApplicationSettings;
私人收藏朋友;
公众观察收集之友
{
收到
{
回报朋友;
}
设置
{
朋友=价值;
RaisePropertyChanged(“朋友”);
}
}
公共ViewModelFriends()
{
ObservableCollection a=新的ObservableCollection();
if(settings.Contains(“userFriends”))
{
string listado=settings[“userFriends”]作为字符串;
var listajson=JsonConvert.DeserializeObject(listado);
if(listajson.profile!=null)
{
foreach(listajson.profile中的objetoslistas.User用户)
{
User\u friend usuario=新用户\u friend(用户);
a、 加上(通常);
}
}
}
朋友=a;
AskFriends();
}
公共异步void AskFriends()
{
ObservableCollection a=新的ObservableCollection();
Uri url=新的Uri(链接);
objetolistas.GetByUserID paquete=新的objetolistas.GetByUserID();
string respuesta=wait metodosJson.jsonPOST(url,paquete);
var respuestajson=JsonConvert.DeserializeObject(respuesta.ToString());
if(respuestajson.error==“”)
{
saveFriends(respuesta);
if(respuestajson.profile!=null)
{
foreach(respuestajson.profile中的objetolistas.User用户)
{
User\u friend usuario=新用户\u friend(用户);
a、 加上(通常);
}
}
}
朋友=a;
}
public void saveFriends(字符串jsonfriends)
{
如果(!settings.Contains(“userFriends”))
添加(“userFriends”,jsonfriends);
其他的
设置[“userFriends”]=jsonfriends;
设置。保存();
}
}
我用来将数据处理到listbox的方法有

公共静态列表GetItemGroups(IEnumerable itemList,Func getKeyFunc)
{
IEnumerable groupList=来自itemList中的项
按getKeyFunc(项)将项分组为g
orderby g.Key
选择新组(g键,g);
返回groupList.ToList();
}
公共类组:列表
{
公共组(字符串名称,IEnumerable项)
:基本(项目)
{
this.Title=名称;
}
公共字符串标题
{
收到
设置
}
}

多亏了所有的

好的,我终于自己解决了,我做了一个这样的对话:

公共类ObservableToGroupedConverter:IValueConverter
{
公共对象转换(对象值,类型targetType,
对象参数,CultureInfo(区域性)
{
var group=(值为ViewModelFriends);
返回metodosAuxiliares.GetItemGroups(group.OrderBy(o=>o.distraw.ToList(),c=>c.online);
}
公共对象转换回(对象值,类型targetType,
对象参数,CultureInfo(区域性)
{
抛出新的NotImplementedException();
}
}
我将conversor添加到资源中,绑定为: