views:

569

answers:

2

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.

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: I'm using Josh Smith's MVVM implementation. I have also read some SO posts on the issue and they have not helped.

Thanks in advance.

Update 2010-01-14:

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

+1  A: 

The new blank row will depend if the collection you are binding implements IEditableCollectionView. see here. That being said i have found that sometimes it works well and other times unexplainably it seems not to, but the IEditableCollectionView is a start

Aran Mulholland
According to the link you presented, ObservableCollection already implements IEditableCollectionView. At least that's how interpreted it.
JP
Although, according to http://msdn.microsoft.com/en-us/library/ms668604.aspx it does not. Thanks for the tip.
JP
A: 

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

*Hits head*

Thanks for your time.

JP