Friday, 5 August 2011

How can I add/remove with a Silverlight 4 DataForm?

More hair pulling ensues, trying to figure out what to do to add or remove rows from the data form.

Again, after much googling, step 1 is to make the buttons visible, which you can do like this:

<toolkit:DataForm CommandButtonsVisibility="All" 
ItemsSource="{Binding Gigs}" ... />

where Gigs is an ObservableCollection of my items.

Alas, that now shows the add/delete buttons, but unfortunately, the add button in my case still wasn’t enabled.

The cause?  For the add button to work, you must ensure that your item has a constructor that takes no parameters!

No comments:

Post a Comment