WPF INotifyPropertyChanged for linked read-only properties

后端 未结 7 1372
小鲜肉
小鲜肉 2020-12-30 09:22

I am trying to understand how to update the UI if I have a read-only property that is dependent on another property, so that changes to one property update both UI elements

7条回答
  •  旧巷少年郎
    2020-12-30 09:57

    If you are only using bar for UI purposes, you could remove it from your model completely. You could bind the UI element to the foo property and use a custom value converter to change the result from foo into foo*foo.

    In WPF there are often a lot of ways to accomplish the same thing. Often times, there isn't a correct way, just a personal preference.

提交回复
热议问题