I am developing an application which uses NavigationWindow
as follows:
NavigationWindow
asMainwindow
.Page0.xaml
which has a 2DataGrid's
(dgMaster and dgDetail) inMaster Detail
scenairo.Window1.xaml
which will be displayed asShowDialog()
on dgDetails'sRow_DoubleClick's
event setter as follows:
Code behind
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
as a DialogBox
, but the DataGrid
is empty. How to load the ItemsSource
of the DataGrid
in Window1.xaml
from the Page0.xaml dgDetails_SelectionChanged
event?
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.