I’m binding my viewmodel and view using resource dictionary as follows
<DataTemplate DataType="{x:Type viewmodels:MyViewModel}">
<Views:MyView />
</DataTemplate>
in MyView, i have dataGrid x:Name=”BoxDataGrid” with DataGrid.RowDetailsTemplate having other dataGrid x:Name=”SpoolsDataGrid”
how to access MyView or datagrids above using code behind in MyViewModel ?
The reason is,i want to load and show contents inside RowDetailsTemplate only when main datagrid row selected (clicked) thru event “RowDetailsVisibilityChanged”.
Thanks.
Correction:
My bad. I want to access MyView not MyViewModel
Just solved this problem using MVVM Light Toolkit – EventToCommand. Other better suggestions are very much welcome.
http://blog.galasoft.ch/archive/2009/11/05/mvvm-light-toolkit-v3-alpha-2-eventtocommand-behavior.aspx
Hope this solution will be useful to others.
don’t need to know the view, in my datagrid view
and in viewmodel
and in viewmodel constructor