using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Automation;

namespace _280191_TreeViewDataBindingTriStateCheck
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();
			this.myTreeView.ItemsSource = new LeaguesDataSource();
		}

	}
	#region classes
	public class League
	{
		public League()
		{
			this.Divisions = new List<Division>();
		}

		public string Name { get; set; }
		public bool? isSelected { get; set; }
		public List<Division> Divisions { get; set; }
	}

	public class Division
	{
		public Division()
		{
			this.Teams = new List<Team>();
		}

		public string Name { get; set; }
		public bool? isSelected { get; set; }
		public List<Team> Teams { get; set; }
	}


	public class Team
	{
		public string Name { get; set; }
		public bool? isSelected { get; set; }
	}

	public class LeaguesDataSource : List<League>
	{
		public LeaguesDataSource()
		{
			League l;
			Division d;

			Add(l = new League() { Name = "League A", isSelected = null });
				l.Divisions.Add((d = new Division() { Name = "Division A", isSelected = null }));
					d.Teams.Add(new Team() { Name = "Team I", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team II", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team III", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team IV", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team V", isSelected = true });
				l.Divisions.Add((d = new Division() { Name = "Division B", isSelected = null }));
					d.Teams.Add(new Team() { Name = "Team I", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team II", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team III", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team IV", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team V", isSelected = false });
				l.Divisions.Add((d = new Division() { Name = "Division C", isSelected = null }));
					d.Teams.Add(new Team() { Name = "Team I", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team II", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team III", isSelected = null });
					d.Teams.Add(new Team() { Name = "Team IV", isSelected = false });
			Add(l = new League() { Name = "League B", isSelected = null });
				l.Divisions.Add((d = new Division() { Name = "Division A", isSelected = null }));
					d.Teams.Add(new Team() { Name = "Team I", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team II", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team III", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team IV", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team V", isSelected = true });
				l.Divisions.Add((d = new Division() { Name = "Division B", isSelected = null }));
					d.Teams.Add(new Team() { Name = "Team I", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team II", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team III", isSelected = null });
					d.Teams.Add(new Team() { Name = "Team IV", isSelected = true });
				l.Divisions.Add((d = new Division() { Name = "Division C", isSelected = null }));
					d.Teams.Add(new Team() { Name = "Team I", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team II", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team III", isSelected = false });
					d.Teams.Add(new Team() { Name = "Team IV", isSelected = true });
					d.Teams.Add(new Team() { Name = "Team V", isSelected = true });
		}
	}
	#endregion
}
