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?DataGridWindow1.xamlPage0.xaml dgDetails_SelectionChanged
これらのコントロールが各 xaml ファイルに個別に属していることは理解していますが、別の xaml からコントロールのデータ コンテキストを表示する方法はありますか (ページ/ウィンドウに関係なく)。
誰かが質問を理解していない場合。教えてください..私はそれをよりよく説明しようとします。