using System.Windows;
using System.Windows.Data;
using System.Windows.Controls;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
using Telerik.Windows.Controls.GridView;

namespace CellTemplateSelector_Example
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();
			
		}

		private void RadButton_Click(object sender, System.Windows.RoutedEventArgs e)
		{
			// TODO: Add event handler implementation here.
			GridViewDataColumn column=new  GridViewDataColumn();
			column.DataMemberBinding=new Binding("Number");
			column.CellTemplateSelector=(DataTemplateSelector)this.Resources["myCellTemplateSelector"];
			this.playersGrid.Columns.Add(column);
		}		
	}


	public class MyCellTemplateSelector : DataTemplateSelector
	{
		public MyCellTemplateSelector()
		{}
		public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
		{
			if (item is Player)
			{
				Player club = item as Player;
				if (club.Flag == true)
				{
					return numberTrue;
				}
				else
				{
					return numberFalse;
				}
			}
			return null;
		}
		public DataTemplate numberTrue{ get; set; }
		public DataTemplate numberFalse{ get; set; }
	}
}
