NavigationWindow
次のように使用するアプリケーションを開発しています。
NavigationWindow
としてMainwindow
。Page0.xaml
シナリオに 2DataGrid's
(dgMaster と dgDetail) がMaster Detail
あります。Window1.xaml
これは、次のようShowDialog()
に dgDetails のRow_DoubleClick's
イベント セッターに表示されます。
Code behind
public void Row_DoubleClick(object sender, RoutedEventArgs e)
{
Window1 my_Window = new Window1();
my_Window.ShowDialog();
}
ポイント番号 2 のコード スニペットは次のとおりです。
// 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();
}
上記のコードは一緒に を として表示しますWindow
がDialogBox
、DataGrid
は空です。イベントからinをロードする方法はItemsSource
?DataGrid
Window1.xaml
Page0.xaml dgDetails_SelectionChanged
これらのコントロールが各 xaml ファイルに個別に属していることは理解していますが、別の xaml からコントロールのデータ コンテキストを表示する方法はありますか (ページ/ウィンドウに関係なく)。
誰かが質問を理解していない場合。教えてください..私はそれをよりよく説明しようとします。