using System;
using System.Windows;
using System.Windows.Controls;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.Calendar;

namespace RadTimePicker
{
	public partial class DateTimePicker : UserControl
	{
		public DateTimePicker()
		{
			InitializeComponent();

			this.DataContext = new TimeViewModel()
			{
				SelectedDate = DateTime.Now.AddDays(-10),
				SelectedTime = TimeSpan.FromHours(12)
			};
		}
	}

	public class CustomTemplate : DataTemplateSelector
	{
		public override System.Windows.DataTemplate SelectTemplate(object item, DependencyObject container)
		{
			var content = item as CalendarButtonContent;

			if (content != null)
			{
				if (content.ButtonType == CalendarButtonType.Date && content.Date < DateTime.Now.Date)
				{
					var buttonContainer = container as Control;
					if (buttonContainer != null)
					{
						//buttonContainer.Visibility = Visibility.Collapsed; //// or put some text - content.Text = "X";
					}
				}
			}
			return DefaultTemplate;
		}

		public DataTemplate DefaultTemplate
		{
			get;
			set;
		}
	}
}
