Do you know how event from “Add_Form” can be listened from “MainForm”? I code in WPF 2010(Visual Studio).
My program has two forms – “MainForm” and “Add_Form”. “MainForm” has “Student_DataGrid” which has a register of students and button(“btn_add_student”) which invokes “Add_Form”(Form which has textblocks for input data of students). After clicking “btn_add_student” shows “Add_Form”, further, I fill in data in textblocks and push the button “btn_add_student”. New student is added in Data Base and “Add_form” is closed. Then “Student_DataGrid” on “MainForm” must be reloaded.
In other words I want to listen event on Add_Form from MainForm. I can do it in C#, but I can’t do it in WPF. I’ll be glad to any help.
Seems you haven’t explored the strength of WPF i.e.
Binding. These tutorials will get you going Binding Tutorial and one from msdn.All you need to do in your case is bind your grid to an
ObservableCollectionand while adding a new student,add the object in this collection. Grid will automatically get refreshed.