Silverlight Telerik GridViewComboBoxColumn 插入问题
我的场景:
我有一个 Telerik Silverlight RadGridView 和一些列,其中之一是
<telerik:RadGridView x:Name="Grid1" DataContext="{StaticResource ViewModelDailyReport}" IsSynchronizedWithCurrentItem="True" ScrollMode="RealTime" AutoGenerateColumns="false" ItemsSource="{Binding LogBookItems}" IsReadOnly="false" Visibility="Visible" >
[...]
<telerik:GridViewComboBoxColumn
Header="My Activity"
DataMemberBinding="{Binding Activity.ID, Mode=TwoWay}"
SelectedValueMemberPath="ID"
DisplayMemberPath="Name"
ItemsSource="{StaticResource ViewModelActivities}">
</telerik:GridViewComboBoxColumn>
[...]
所以我在 ViewModel 中的项目集合上有一个 TwoWay 绑定。
一切正常,除了当我插入一个新项目(使用 RadGrid BeginInsert 命令)时:当用户从下拉列表中选择一个项目时,它在单元格中始终为空白...
绑定集合有一个新项目(在插入事件上),但没有办法将新添加的项目与组合框绑定。
有什么窍门呢?
谢谢
My scenario:
I have a Telerik Silverlight RadGridView With some columns, and one of them is
<telerik:RadGridView x:Name="Grid1" DataContext="{StaticResource ViewModelDailyReport}" IsSynchronizedWithCurrentItem="True" ScrollMode="RealTime" AutoGenerateColumns="false" ItemsSource="{Binding LogBookItems}" IsReadOnly="false" Visibility="Visible" >
[...]
<telerik:GridViewComboBoxColumn
Header="My Activity"
DataMemberBinding="{Binding Activity.ID, Mode=TwoWay}"
SelectedValueMemberPath="ID"
DisplayMemberPath="Name"
ItemsSource="{StaticResource ViewModelActivities}">
</telerik:GridViewComboBoxColumn>
[...]
So I Have a TwoWay binding on a Collection of Items in a ViewModel.
All works fine, except when I insert a new item (with RadGrid BeginInsert command): when user chooses an item from the dropdown, it is always blank in the cell...
The bound collection has a new item (on insert event), but there is no way to bind the newly added item with combobox.
What is the trick?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保 LogBookItem 类中有默认构造函数。
在默认构造函数中,您可以初始化默认值并创建一个新的 Activity 实例,因为您要绑定到它的 ID。
Make sure you have a default constructor in the LogBookItem class.
In the default constructor, you can initialize your default values and also create a new Activity instance, since you are binding to it's ID.