からメインウィンドウの子として第二のフォームを開くたぶん私は必要に応じて変更し、タイトルに自分自身を明確にすることはありません。今、私は説明をステップ:WPF + Windowsフォーム、最初のフォーム
私はWPF(原因グラフィックス)で行われたプログラムを持っています。 MainWindowはボタン付きの最初のFormを開き、Form1はMainWindowのUIを変更し、Form2を開いてMainWindowのUIを変更する必要があるはずですが、 Form1からForm2を開きます。
MainWindow.xaml.cs
internal static MainWindow main; //It allows me to put the Form1 in the same context in order to change the UI
private void start_button_Click(object sender, RoutedEventArgs e)
{
Form1 frm = new Form1(this);
frm.Show();
}
のForm1.cs
//function that allow me to communicate with the MainWindow
private MainWindow main1 = null;
public Form1(MainWindow callingForm)
{
main1 = callingForm as MainWindow;
InitializeComponent();
}
//Load function
private void Form1_Load(object sender, EventArgs e)
{
//do some stuff changing MainWindow UI
Form2 frm = new Form2(main1); //no compilation error
frm.Show();
}
さて、Form2のは開けません:
はここにいくつかのコードです。私はまた、MainWindowにあるForm1で何もない空白を呼び出そうとしました。私がしなければならないこと?注記:Form2でメインウィンドウのUIを変更する必要があり、Form2がForm1の計算の最後にのみ開くようにする必要があります。あなたがメインウィンドウからウィンドウを開こうとしている場合は
'Form'とはどのような名前空間ですか?それはWinFormsのためのもののように見える? –
名前空間 "Application__WPF" @lll – Northumber
'Dispatcher'で' Form2'の関数呼び出しをラップすることはできますか?このようなディスパッチャとDispatcher.BeginInvoke' –