XamlParseException Failed to assign to property. Binding not working with attached property

前端 未结 2 1377
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-12 17:40

I want to create custom text box with attached property for Windows Store app. I am following this solution. Now it uses hard coded value as property value but I want to set

2条回答
  •  伪装坚强ぢ
    2021-01-12 17:57

    Incorrect

    public static readonly DependencyProperty TypeProperty =
        DependencyProperty.RegisterAttached("Type", typeof(InputType), typeof(TextBox), new PropertyMetadata(default(InputType), OnTypeChanged));
    

    Correct

    public static readonly DependencyProperty TypeProperty =
                DependencyProperty.RegisterAttached("Type", typeof(InputType), typeof(Input), new PropertyMetadata(default(InputType), OnTypeChanged));
    

提交回复
热议问题