Search code examples
silverlight-4.0mvvmwcf-ria-services

Adding additional properties in ViewModel


I have a Silverlight 4 app using EF & WCF RIA Services with a SQL DB. I have a Tasks table that I want to display in a grid or listbox and I want to do a custom grouping. The custom grouping would be Overdue, today, tomrrow, next 7 days and future.

If I understand the concepts of MVVM correctly, I should be creating a custom property for my Tasks object in the TasksViewModel. But I am not sure how to do this.

I have the Tasks entity that is automatically created in the entity data model and I have a GetTasks method in the DomainService that I call in my viewmodel.

Any help will be greatly appreciated.


Solution

  • You should have access to those types from the client. You can create a list of the Task entity on your ViewModel that you can bind to.

    private List<Task> _tasks;
    public List<Task> Tasks
    {
         get { return _tasks; }
         set {
              _tasks = value;
              NotifyPropertyChanged("Tasks");
              }
    }
    

    Or you can create a client side poco to map to if you don't want to bind directly to entities.