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

namespace DataFormBugDemo
{
    public class DataFormHotKeySettingsField : DataFormDataField
    {
        protected override DependencyProperty GetControlBindingProperty()
        {
            return HotKeyInputBox.HotKeyProperty;
        }

        protected override Control GetControl()
        {
            var dependencyProperty = GetControlBindingProperty();
            var inputBox = new HotKeyInputBox();
            if (DataMemberBinding != null)
            {
                var binding = DataMemberBinding;
                binding.Mode = BindingMode.TwoWay;
                inputBox.SetBinding(dependencyProperty, binding);
            }
            inputBox.SetBinding(IsEnabledProperty, new Binding("IsReadOnly") { Source = this, Converter = new InvertedBooleanConverter() });
            inputBox.SetBinding(TextBox.TextProperty, new Binding("Name"));
            return inputBox;
        }
    }
}
