title: XamlParseException Failed to assign to property. Binding not working with attached property
body: <p>I want to create custom text box with attached property for Windows Store app. I am following <a href="https://stackoverflow.com/questions/1977202/silverlight-numeric-textbox">this solution</a>. Now it uses hard coded value as property value but I want to set value using binding, but it's not working. I tried to search a lot but didn't helped me any solution.</p>
  
  <p>The exception details is like this</p>
  
  <blockquote>
    <p>An exception of type 'Windows.UI.Xaml.Markup.XamlParseException'
    occurred in CustomTextBox.exe but was not handled in user code</p>
    
    <p>WinRT information: Failed to assign to property
    'CustomTextBox.Input.Type'.</p>
  </blockquote>
  
  <p>MainPage.xaml</p>
  
  <pre><code>&lt;!-- local:Input.Type="Email" works --&gt;
  &lt;!-- local:Input.Type="{Binding SelectedTextboxInputType}" not working --&gt;
  
  &lt;TextBox x:Name="txt" local:Input.Type="{Binding SelectedTextboxInputType}" Height="30" Width="1000" /&gt;
  
  &lt;ComboBox x:Name="cmb"  ItemsSource="{Binding TextboxInputTypeList}" SelectedItem="{Binding SelectedTextboxInputType}" Height="30" Width="200" 
            Margin="451,211,715,527" /&gt;
  </code></pre>
  
  <p>MainPage.xaml.cs</p>
  
  <pre><code>public sealed partial class MainPage : Page
  {
      public MainPage()
      {
          this.InitializeComponent();
          DataContext = new ViewModel();
      }
  }
  </code></pre>
  
  <p>Input.cs</p>
  
  <pre><code>//InputType is enum
  public static InputType GetType(DependencyObject obj)
  {
      return (InputType)obj.GetValue(TypeProperty);
  }
  
  public static void SetType(DependencyObject obj, InputType value)
  {
      obj.SetValue(TypeProperty, value);
  }
  
  public static readonly DependencyProperty TypeProperty =
      DependencyProperty.RegisterAttached("Type", typeof(InputType), typeof(TextBox), new PropertyMetadata(default(InputType), OnTypeChanged));
  
  private static void OnTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  {
      if (e.NewValue is InputType)
      {
          var textBox = (TextBox)d;
          var Type = (InputType)e.NewValue;
          if (Type == InputType.Email || Type == InputType.URL)
          {
              textBox.LostFocus += OnLostFocus;
          }
          else
          {
              textBox.TextChanged += OnTextChanged;
          }
      }
  }
  </code></pre>
  
  <p>ViewModel.cs</p>
  
  <pre><code>public class ViewModel : BindableBase
  {
      public ViewModel()
      {
          TextboxInputTypeList = Enum.GetValues(typeof(InputType)).Cast&lt;InputType&gt;();
      }
  
      private InputType _SelectedTextboxInputType = InputType.Currency;
      public InputType SelectedTextboxInputType
      {
          get { return _SelectedTextboxInputType; }
          set { this.SetProperty(ref this._SelectedTextboxInputType, value); }
      }
  
      private IEnumerable&lt;InputType&gt; _TextboxInputTypeList;
      public IEnumerable&lt;InputType&gt; TextboxInputTypeList
      {
          get { return _TextboxInputTypeList; }
          set { this.SetProperty(ref this._TextboxInputTypeList, value); }
      }
  }
  </code></pre>