This is a migrated thread and some comments may be shown as answers.

ItemsSource is not updated on insert?

2 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rune
Top achievements
Rank 1
Rune asked on 03 Jul 2012, 06:02 PM
I Have a GridView bound to a ItemsSource and I'm using mvvm. The problem is when I click "Insert" and/or "Click here to add new item" nothing happens. I can edit the data in the rows and delete row and then grid updates. But not insert new rows.

WPF Code:
<telerik:RadGridView ItemsSource="{Binding WellCompletionEvaluation.CompletionItems}" AutoGenerateColumns="False" CanUserInsertRows="True" Grid.Row="24" Grid.Column="0" Grid.ColumnSpan="6"
               MinHeight="200" MaxHeight="500" ShowInsertRow="True" ShowGroupPanel="False"
               CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed">

In my model I have this kind of code:
public class WellCompletionEvaluationViewModel : ValidatedViewModelBase
    {
        private readonly JobInfoOperationWellCompletionEvaluation model;
 
        public ObservableCollection<WellCompletionEvaluationCompletionItemsViewModel> CompletionItems { get; private set; }
 
 
        public WellCompletionEvaluationViewModel(JobInfoOperationWellCompletionEvaluation model)
        {
            this.model = model;
 
            WTConfiguration = new WellCompletionEvaluationWTConfigurationViewModel(model.WTConfiguration);
 
            this.CompletionItems = new ObservableCollection<WellCompletionEvaluationCompletionItemsViewModel>(
                from p in this.model.completionItems
                select new WellCompletionEvaluationCompletionItemsViewModel(p));
 
             
        }
 
        public JobInfoOperationWellCompletionEvaluation Model { get { return this.model; } }
 
 
        public WellCompletionEvaluationWTConfigurationViewModel WTConfiguration
        {
            get;
            set;
        }
}


ValidatedViewModelBase implements IDataErrorInfo and ViewModelBase that implements INotifyPropertyChanged and IDisposable

Is there something wrong with my view model+

Best Regards
Rune

2 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 04 Jul 2012, 07:05 AM
Hello Rune,

Could you verify whether you have a default (parameterless) constructor for your business object ?  

Greetings,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rune
Top achievements
Rank 1
answered on 04 Jul 2012, 07:29 AM
Awesome that helps :)

Thank you very much!
Tags
GridView
Asked by
Rune
Top achievements
Rank 1
Answers by
Maya
Telerik team
Rune
Top achievements
Rank 1
Share this question
or