【发布时间】:2021-09-21 15:08:43
【问题描述】:
我希望有多个选定日期的日历项目,这些日期将在 C# 中生成。 那么 wpf 中 SelectedDates 属性的绑定过程是怎样的呢? 可以将 Date 返回到绑定目标的 C# 代码是什么? 这是我的一些 xaml 代码
<Calendar x:Name="_calendar"
Style="{DynamicResource CalendarStyle1}"
CalendarDayButtonStyle="{DynamicResource CalendarDayButtonStyle1}"
CalendarButtonStyle="{DynamicResource CalendarButtonStyle1}"
IsManipulationEnabled="True"
SelectionMode="MultipleRange"
SelectedDate="{Binding }">
</Calendar>
【问题讨论】:
-
@zaggler 不是真的...没有答案如何绑定到
SelectedDates -
@Selvin 有一个答案,
Wouldn't you have a DateTime property in your VM that is bound to the calendar and that raises PropertyChanged?这种方法有什么不清楚的地方?如果不理解,我建议阅读 mvvm 以了解绑定和或INotifyProperty更改的工作原理。 -
@zaggler Everything ..
SelectedDates不是DateTime... 它是只读属性 -
SelectedDates是只读的,您需要定位SelectedDate。您必须拥有可以保存多个日期的内容,例如用于多个日期的ObservableCollection<DateTime>。 -
目标
SelectedDate绑定范围...有趣
标签: c# .net wpf visual-studio xaml