wpf trouble using dependency properties in a UserControl

前端 未结 3 1671
萌比男神i
萌比男神i 2021-01-12 08:01

I made a UserControl that is meant to be updated once every few seconds with data from a serial port. This UserControl should be very simple, consisting of a Label for a fi

3条回答
  •  旧巷少年郎
    2021-01-12 08:14

    If you want to bind to properties of the control, you should specify so in the binding. Bindings are evaluated relative to DataContext if their source isn't explicitly specified, so your binding doesn't bind to your control, but to the inherited context (which is likely missing the property you're binding to). What you need is:

提交回复
热议问题