I am developing an application which uses NavigationWindow as follows
1. NavigationWindow as Mainwindow
2. Page0.xaml which has a 2 datagrid's (dgMaster and dgDetail) in Master Detail scenairo.
3.Window1.xaml which will be displayed as ShowDialog() on dgDetails's Row_DoubleClick's event setter as follows
<DataGrid.ItemContainerStyle><Style TargetType="DataGridRow"><EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/> </Style></DataGrid.ItemContainerStyle>
public void Row_DoubleClick(object sender, RoutedEventArgs e) { Window1 my_Window = new Window1(); my_Window.ShowDialog(); }
for point number 2, the code snippet is as follows
// on datagrid row selection changed, it should load the ItemsSource in the Window1 datagrid. dg3 is the datagrid in Window1. private void dgDetails_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.db = new testDB_Entities(); string IDMapper = (dgDetails.SelectedItem as Details).Name; var Query1 = from a in this.db.Details orderby a.ID == IDMapper select a; dg3.DataContext = null; dg3.DataContext = Query1; dg3.Items.Refresh(); }
the above codes together displays the window in form of a dialog box but the datagrid is empty.
how to load the ItemsSource of the datagrid in Window1.xaml from the Page0.xaml.
I understand that these controls belong separately to each xaml files, but is there a way to display a controls datacontext from another xaml ( regardless a page /window).
if anybody dont understand the question. please let me know.. i will try to explain it better. Thanks in advance