using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Controls;
using Bindable.Linq;
using Telerik.Windows.Controls.Charting;

namespace SilverlightApplication3
{
	public partial class Page : UserControl
	{
		public Page()
		{
			InitializeComponent();

			RadChart1.DefaultView.ChartTitle.Content = "Units in stock (more than 100 units)";

			SeriesMapping mapping = new SeriesMapping();
			mapping.ItemMappings.Add(new ItemMapping("UnitsInStock", DataPointMember.YValue));
			mapping.ItemMappings.Add(new ItemMapping("Category", DataPointMember.Label));
			RadChart1.SeriesMappings.Add(mapping);

			ObservableCollection<UserData> dataList = new ObservableCollection<UserData>();
			RadChart1.ItemsSource = from data in dataList.AsBindable()
									   where data.UnitsInStock > 100
									   select data;

			dataList.Add(new UserData { UnitsInStock = 70, Category = "Beverages"});
			dataList.Add(new UserData { UnitsInStock = 170, Category = "Dairy Products" });
			dataList.Add(new UserData { UnitsInStock = 340, Category = "Grains Cereals" });
			dataList.Add(new UserData { UnitsInStock = 240, Category = "Produce" });
			dataList.Add(new UserData { UnitsInStock = 40, Category = "Seafood" });
		}
	}

	public class UserData
	{
		public int UnitsInStock
		{
			get; 
			set;
		}

		public string Category
		{
			get; 
			set;
		}
	}
}
