DatePicker 的 IsSynchronizedWithCurrentItem (或等效项)?
我目前有一个绑定到 ObservableCollection 的组合框
<ComboBox ItemsSource="{Binding Past}" DisplayMemberPath="Date" IsSynchronizedWithCurrentItem="True"/>
,使用“IsSynchronizedWithCurrentItem”,它与一组标签“同步”,这些标签在一组标签中显示下面的数据,例如:
<Label DataContext="{Binding SelectedDate}" Content="{Binding Minimum}" />
因为使用 DatePicker 选择日期要容易得多(就像 WPF 工具包那样,http://wpf.codeplex.com/)而不是带有超过其中有 300 个日期,是否有办法设置“IsSynchronizedWithCurrentItem”之类的内容,以便 DatePicker 可以控制“当前日期”?
谢谢
I currently have a combobox with bound to an ObservableCollection
<ComboBox ItemsSource="{Binding Past}" DisplayMemberPath="Date" IsSynchronizedWithCurrentItem="True"/>
Using, 'IsSynchronizedWithCurrentItem' it "synchronizes" with a set of labels that show the data below in a set of labels like:
<Label DataContext="{Binding SelectedDate}" Content="{Binding Minimum}" />
As it is a lot easier to select a date using a DatePicker (like the WPF Toolkit one, http://wpf.codeplex.com/) rather than a combobox with over 300 dates in it, is there someway to set something like 'IsSynchronizedWithCurrentItem' so that the DatePicker can control the 'current date'?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过在视图模型中创建“CurrentDate”属性解决了这个问题:
然后为第一个和第二个属性创建两个属性。最后一个日期:
然后使用 DatePicker 绑定到这些属性:
这意味着 DatePicker 将仅限于第一个和最后一个日期:最后日期,并且可以选择一个日期,链接到详细信息。
I solved this by creating a 'CurrentDate' Property in my View Model:
and then creating two property's for the first & the last dates:
and then binding to these properties using the DatePicker:
This meant that the DatePicker would be limited to the first & the last dates, and one can choose a date, linked to the details.