开发者

Bind WPF Calendars to Each Other Across Controls

开发者 https://www.devze.com 2023-04-11 10:47 出处:网络
I have two User Controls, and a Calendar in each.I need to be able to bind the selected date range in one to the selected date range in the other.Is there an 开发者_运维问答easy way to do this?If both

I have two User Controls, and a Calendar in each. I need to be able to bind the selected date range in one to the selected date range in the other. Is there an 开发者_运维问答easy way to do this?


If both of them share the same ViewModel then you can just bind to the same property.

If they have separate ViewModels then you're approaching the problem in the wrong way. A UserControl shouldn't bind to things outside of its boundaries and binding to a sibling controls child is even worse. This will make your UI elements tightly coupled with each other and you wouldn't know why one broke because you made change in the other one.

Consider sharing the same ViewModel instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号