using System.Windows.Automation;
using System.Windows.Data;

namespace Silverlight_Binding_TreeView
{
	public class CheckStateConverter : IValueConverter
	{
		public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			bool isChecked = (bool)value;

			if (isChecked)
			{
				return ToggleState.On;
			}
			else
			{
				return ToggleState.Off;
			}
		}

		public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			ToggleState checkState = (ToggleState)value;

			if (checkState == ToggleState.On)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}
