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

Observe-Notify problem

1 Answer 46 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 24 Nov 2010, 08:46 PM
Hi guys, I am new to WPF all together so not strong on concepts.

I have generated RadgridView and based on the selection of the cell in this Radgridview, I want to populate a new RadgridView.

public partial class SummaryTable : UserControl
  {
      public SummaryTable()
      {
          this.InitializeComponent();
      }
      private void MainGridView_SelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
      {
          IList<GridViewCellInfo> cellList =  this.radView1.SelectedCells;
         GridViewCellInfo cellInfo = (GridViewCellInfo)cellList.First();
          
         // Initialize MyView object based on cellInfo.Item to capture the details of whole row
      }
}


The problem is how to pass this MyView object to Top-level ViewModel class so that it can initialize the second table that I want to generate based on the MyView object. I was thinking that when Top-level class will get notified about the new MyView object then it will set the DataSource for the second table to populate it.

Please let me know if you have any other suggestions. I am a new player :)

Thanks,
Mark

1 Answer, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 26 Nov 2010, 10:20 AM
Hi Mark,

Based on what I managed to understand from your description, I assume that the top-level ViewModel is the the DataContext of the whole window and both grids get their data from it via different properties. So if we have grid1 and grid2, grid1 get its data from ViewModel.Data1 and grid2 gets its data from ViewModel.Data2.

In the event handler, you have access to the ViewModel since it is in your current scope. You can create a new property on the ViewModel called MyView that has a setter. When the event happens, build the info that you need and set it to this property of the ViewModel. In the setter of this property inside the ViewModel, do the needed stuff and update Data2. In this way grid2 will automatically be updates since it is bound to Data2.

If I have misunderstood your description of the problem, please try to provide a more structured explanation about your exact setup and goal. Sending us your sample project will also help a lot.

I hope this helps.

All the best,
Ross
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or