Telerik ScheduleView Appointments CollectionChanged 使用空对象触发
我正在 ViewModel 上的 Appointments ObservableCollection 上处理 CollectionChanged,以捕获新添加的约会以及 UI 中约会的任何更改。 但我发现,当用户双击 ScheduleView 并出现“添加新约会”窗口时(但在输入任何信息之前),就会触发 CollectionChanged 事件。因此,在 CollectionChanged 处理程序中,我得到了空约会对象。
有什么想法吗?
i am handling CollectionChanged on Appointments ObservableCollection on my ViewModel to catch newly added appointments and any changes in appointments in the UI.
but i found that CollectionChanged event fires just when user double click the ScheduleView and Add new appointment window appears (but before entering any info.) so in CollectionChanged handler I got empty appointment object .
any ideas please ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ObservableCollection
实现INotifyCollectionChanged
接口,该接口应该在集合更改时通知您,而不是在集合中项目的属性更改时通知您。我从未使用过 Telerik 的 ScheduleView,但我猜想“当您添加新约会时”您会在事件中获得正确的对象。 所以,您有一个对新约会对象的引用,它只是空的。因为它应该是空的(UI 中尚未输入任何内容,也没有写回对象)。
但是,因为当 Telerik 的控件更新该约会对象时您拥有对同一对象的引用,所以您的对象将是相同的(具有正确的信息)。
可能还有另一个 Telerik 事件或命令 用于保存此约会,但您应该对收到的事件或命令没问题,因为我确信 Telerik 将使用该对象来“填写”约会。
ObservableCollection
implementsINotifyCollectionChanged
interface which is supposed to notify you when the collection changes and not when an item's property changes in the collection.I never used Telerik's ScheduleView, but I guess 'when you add a new appointment' you get the correct object in the event. So, you have a reference to the new appointment object, it is just empty. Because it is supposed to be empty (nothing entered in the UI yet, nothing written back to the object).
But because you have the reference to the same object when Telerik's control updates that appointment object then your object will be the same (with the correct information).
Probably there is another Telerik event or command for saving this appointment, but you should be okay with the received one, because I'm sure telerik will use that object to 'fill out' the appointment.