c# - dynamically generate a windows 10ish tile-menue in Windows Forms -
does know way generate tiles, sorted groups dynamically?
something tile view in windows 10(or in case devexpress example)
the goal programmatically add groups or tiles this: list.add("groupname","tilename"). groupname primary key of group , foreignkey of tile.
here's simple example created started model part.
let's have tile class represents tile. in case, put directly group name part of tile, have group
class , store groupid
in tile.
public class tile { public string title { get; set; } public string group { get; set; } }
now, let's have created few tiles :
var tiles = new tile[] { new tile { title = "tile 1", group = "group 1" }, new tile { title = "tile 2", group = "group 1" }, new tile { title = "tile 3", group = "group 1" }, new tile { title = "tile 4", group = "group 2" }, new tile { title = "tile 5", group = "group 2" }, new tile { title = "tile 6", group = "group 2" }};
now, can group tiles group
parameter using simple linq query:
var groupedtiles = t in tiles group t t.group g select new { group = g.key, tiles = g.tolist() };
grouptiles
contain list of "groups" contain each list of attached tiles. should able bind view.
here's console output:
foreach (var group in groupedtiles) { console.out.writeline(group.group); foreach (var tile in group.tiles) { console.out.writeline("\t" + tile.title); } }
hope helps.
wiki
Comments
Post a Comment