I have 2 WPF windows, MainWindow & ChildWindow. I would like a click event in the mainwindow to open a childwindow (I will be passing some information to the child window). In the Child Window I would like the MainWindow to update on Submit on Click in Child Window. WorkFlow: MainWindow --> TextBlock click --> create New ChildWindow params: x_coord, y_coord, line number --> show child window child window --> on submit btn click --> send text as string back to main window
public MainWindow()
{
InitializeComponent();
WorkspaceVersion.MouseLeftButtonDown += new MouseButtonEventHandler(WorkspaceVersion_MouseLeftButtonDown); // text block click event
}
// mouse left button down
private void WorkspaceVersion_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point position = e.GetPosition(WorkspaceVersion);
var i = Math.Round(position.Y/15); // line number
var commentWindow = new CommentWindow(position, i);
commentWindow.Show();
}
/////////////// child window /////////////
// probably need to create a custom event to raise, then register to in mainwindow
public CommentWindow()
{
InitializeComponent();
}
protected void SubmitButton_OnClick(object sender, EventArgs e)
{
string comment = new TextRange(CommentBox.Document.ContentStart, CommentBox.Document.ContentEnd).Text;
// raise event with custom args????
// main window should be listening for this event??
this.Close();
}