WPF数据网格允许用户添加行? [英] WPF datagrid allow user to add rows?

查看:199
本文介绍了WPF数据网格允许用户添加行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绑定到我的观察的集合有底部的空白行,使用户可以添加更多的信息我的WPF Datagrid中。我已经成功地绑定的数据,即我可以看到它。

I would like my WPF Datagrid that is bound to my observable collection to have the blank row at the bottom so that the user can add more info. I've successfully bound the data, i.e. I can see it.

为什么没有显示新空白行?这里是我的XAML声明:

Why is the 'new' blank row not showing? Here is my xaml declaration:

<UserControl.Resources>
  <CollectionViewSource x:Key="MyItems" Source="{Binding Path=AllItems}">
  </CollectionViewSource>
</UserControl.Resource>

<my:DataGrid HorizontalAlignment="Stretch"
  AutoGenerateColumns="True"
  SelectionUnit="FullRow"
  CanUserAddRows="True"
  CanUserDeleteRows="True"
  DataContext="{StaticResource MyItems}"
  ItemsSource="{Binding}">



PS:我使用的约什·史密斯的MVVM实现。我也看过一些SO 职位的问题,的的: //stackoverflow.com/questions/1751897/how-to-get-the-wpf-toolkit-datagrid-to-show-new-rows-when-bound-to-dataset\">they 没有<一个HREF =http://stackoverflow.com/questions/1579382/wpf-datagrid-row-for-new-entry-not-visible>帮助。

PS: I'm using Josh Smith's MVVM implementation. I have also read some SO posts on the issue and they have not helped.

在此先感谢

更新2010-01-14:

当用户控件加载事件发生时,CanUserAdddRows是假的。我怀疑是有事情做与上市的这里

When the usercontrol load event occurs, "CanUserAdddRows" is false. I suspect is has something to do with the conditions listed here.

推荐答案

发现问题。我在这是我的ObservableCollection的一部分对象的构造函数未声明公开。

Found the problem. My constructor in the object that's part of my ObservableCollection wasn't declared public.

*命中头部*

感谢您的时间。

这篇关于WPF数据网格允许用户添加行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆