Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to choose Datagrid grouping order in WPF?
    primarykey
    data
    text
    <p>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.</p> <p>It's a small app that polls a game server for player information and binds it to a <code>DataGrid</code>. The data is grouped by team, which can be one of four values: Blue, Red, Spectator, or None.</p> <p>I've got the Linq query working fine, and the <code>DataGrid</code> 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.</p> <p>Is there any way I can force the groups into the order above?</p> <p>Here is the Linq query (addr is the server ip):</p> <pre><code>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&lt;Player&gt; (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 =&gt; p.rank); ListCollectionView collection = new ListCollectionView(server); collection.GroupDescriptions.Add(new PropertyGroupDescription("team")); player_list.ItemsSource = collection; } </code></pre> <p>A second problem is that neither of the OrderBys seem to have an effect.</p> <p>Any help would be appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload