title: How do I bind a domain context to a data grid ? Ria Services + Silverlight
body: <p>These past days I've tried to understand the concept of invoked methods and domain contexts, but some things are still not so clear to me.</p>
  
  <p>In my StudentDomainService I have this method:</p>
  
  <pre><code>[Invoke]
      public IEnumerable&lt;Student&gt; GetStudents()
      {
          return _studentRepository.GetStudents();
      }
  </code></pre>
  
  <p>This returns a list of students that I want to bind to my datagrid using a viewmodel.</p>
  
  <p>In my StudentViewModel I have:</p>
  
  <pre><code>private StudentDomainContext _studentDomainContext;
  private InvokeOperation&lt;IEnumerable&lt;Student&gt;&gt; _students;
  public StudentViewModel()
      {
          _studentDomainContext = new StudentDomainContext();
          _students = _studentDomainContext.GetStudents(OnInvokeCompleted, null);
      }
  
      public void OnInvokeCompleted(InvokeOperation&lt;IEnumerable&lt;Student&gt;&gt; studs)
      {
          if (studs.HasError)
          {
              studs.MarkErrorAsHandled();
          }
          else
          {
              var result = studs.Value;
          }
      }
  
      public InvokeOperation&lt;IEnumerable&lt;Student&gt;&gt; Students
      {
          get { return _students; }
          set
          {
              _students = value;
              RaisePropertyChanged("Students");
          }
  
      } 
  </code></pre>
  
  <p>And in StudentView I have a datagrid and I'm trying to bind to the Students property like this:</p>
  
  <pre><code>ItemsSource="{Binding Students}"
  </code></pre>
  
  <p>But when I start the application the data grid appears but it's not displaying anything. Can anyone please tell me what I'm doing wrong?</p>
  
  <p><strong>UPDATE</strong> I think the problem is that the OnInvokeCompleted() method is not executing on the UI, but I'm not really sure.    </p>