How to implement two-way binding on a property?

前端 未结 2 1236
野性不改
野性不改 2020-12-22 06:16

I know there are lots of questions about dependency properties, and I have looked at many of them, but none of them seems to solve my problem.

I have a Window like t

2条回答
  •  离开以前
    2020-12-22 06:41

    Try changing this line:

    public static readonly DependencyProperty MyTextProperty = DependencyProperty.Register("MyText",
    typeof(string), typeof(TextInputWrapper), new PropertyMetadata("Empty"));
    

    To this:

    public static readonly DependencyProperty MyTextProperty = DependencyProperty.Register("MyText",
        typeof(string), typeof(TextInputWrapper), new FrameworkPropertyMetadata("Empty", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
    

提交回复
热议问题