|
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
namespace GridViewSamples.DataModel
{
public class Item
{
static List<Windows.UI.Color> colors = typeof(Windows.UI.Colors)
.GetRuntimeProperties()
.Select((x) => (Windows.UI.Color)x.GetValue(null)).ToList<Windows.UI.Color>();
public int Id { get; set; }
public int GroupId { get; set; }
public Windows.UI.Color GroupColor
{
get
{
int index = GroupId;
while (index > colors.Count - 1)
{
index -= colors.Count;
}
return colors[index];
}
}
}
public class Group
{
// static integer which should be used as group Id for the new group
private static int newGroupId = 1;
private int _id;
public static Group GetNewGroup()
{
Group gr = new Group();
gr.Id = newGroupId;
return gr;
}
private Group()
{
Items = new ObservableCollection<Item>();
}
public int Id
{
get
{
return _id;
}
set
{
_id = value;
if (newGroupId <= _id)
{
// update newGroupId so that Id is unique
newGroupId = _id + 1;
}
}
}
public ObservableCollection<Item> Items { get; set; }
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am the ComponentOne product manager at GrapeCity. I love .NET but especially the XAML platforms. You'll find me blogging about these awesome technologies and at various code camps, techfests and tradeshows.