Hi guys,
I've just started to learn WPF/C# and I picked a project which would actually be useful to me instead of variations of Hello, World! programs.
It's a small app that polls a game server for player information and binds it to a Datagrid. The data is grouped by team, which can be one of four values: Blue, Red, Spectator, or None.
I've got the Linq query working fine, and the Datagrid grouping is almost good, except for one small problem: the order of the four teams groups is different every time. Sometimes Red is first, sometimes None, etc.
Is there any way I can force the groups into the order above?
Here is the Linq query (addr is the server ip):
private void get_server(string addr)
{
var loc = "http://ukcs.gameme.com/api/serverinfo/" + addr + "//players";
XDocument doc = XDocument.Load(@loc);
var server = new ObservableCollection<Player>
(from player in doc.Descendants("player")
orderby player.Element("rank").Value
select new Player
{
name = player.Element("name").Value,
team = player.Element("team").Value,
frags = player.Element("kills").Value + ":" + player.Element("deaths").Value,
rank = int.Parse(player.Element("rank").Value)
});
server.OrderBy(p => p.rank);
ListCollectionView collection = new ListCollectionView(server);
collection.GroupDescriptions.Add(new PropertyGroupDescription("team"));
player_list.ItemsSource = collection;
}
A second problem is that neither of the OrderBys seem to have an effect.
Any help would be appreciated!