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

namespace ComboInNewRowOnly
{
	/// <summary>
	/// Interaction logic for SelectiveEditor.xaml
	/// </summary>
	public partial class SelectiveEditor : UserControl
	{
		public SelectiveEditor()
		{
			InitializeComponent();
			this.Loaded += new RoutedEventHandler(SelectiveEditor_Loaded);
			this.Combo.ItemsSource = new[] { "one", "two", "three" };
		}

		void SelectiveEditor_Loaded(object sender, RoutedEventArgs e)
		{
			var parentRow = this.ParentOfType<GridViewRow>();
			if (parentRow is GridViewNewRow)
			{
				this.Combo.Visibility = Visibility.Visible;
				this.Combo.SetBinding(RadComboBox.SelectedValueProperty, new Binding("Description") { Mode = BindingMode.TwoWay });
				this.TextBox.Visibility = Visibility.Collapsed;

			}
			else
			{
				this.Combo.Visibility = Visibility.Collapsed;
				this.TextBox.Visibility = Visibility.Visible;

				this.Combo.ClearValue(RadComboBox.SelectedValueProperty);
			}
		}
	}
}