![](/img/trans.png)
[英]How to do Data Binding for Textblock within a LongListselector in windows phone app?
[英]How to binding friendlist as longlistselector in windows phone 8
我在Windows Phone中進行應用聊天,我的類名為GetFriendResponse
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RAMACHAT.Model
{
public class FriendInfo
{
public bool success { get; set; }
public int statusCode { get; set; }
public string message { get; set; }
public _user data { get; set; }
}
public class GetFriendResponse
{
public bool success { get; set; }
public int statusCode { get; set; }
public string message { get; set; }
public string _id { get; set; }
public List<_user> data { get; set; }
}
和類_user為
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RAMACHAT.Model
{
public class _user
{
public string _id { get; set; }
public string username { get; set; }
public string avatar { get; set; }
public bool isOnline { get; set; }
public bool isFollow { get; set; }
}
}
}
現在我想在服務器響應用戶frendslist時將frendslist設為longlistselector
string result = await App.client.getAllFriends();
string resultHistory = await App.client.getChatHistory();
resultObject = JsonConvert.DeserializeObject<GetFriendResponse>(result);
var resultHistoryObject = JsonConvert.DeserializeObject<HistoryResponse>(resultHistory);
List<AlphaKeyGroup.AlphaKeyGroup1<_user>> DataSource = AlphaKeyGroup.AlphaKeyGroup1<_user>.CreateGroups(resultObject.data,
System.Threading.Thread.CurrentThread.CurrentUICulture,
(_user s) => { return s.username; }, true);
friendList.ItemsSource = DataSource;
但是它不起作用,任何人都有修復它的想法,非常感謝!
由於您尚未共享設計代碼塊,因此可能是XAML頁面綁定的問題。 最好您將此 MSDN頁面用於longlistselector綁定。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.