Possible Duplicate:
Passing arguments to event handler
I'm trying to handle an event raised from a MenuItem.Click
. The catch is, I need some way to pass some custom arguments with it (specifically, two integers representing row and column).
private void Window_Loaded(object sender, RoutedEventArgs e)
{
...
MenuItem froNewChild = new MenuItem();
froNewChild.Header = "Insert new box";
froNewChild.Click += new RoutedEventHandler(froNewChild_Click);
// froNewChild.Click += new RoutedEventHandler(froNewChild_Click, column, row);
FlowRectangleOptions.Items.Add(froNewChild);
...
}
private void froNewChild_Click(object sender, RoutedEventArgs e) //+column & row
{
FlowDocument.allColumns[column-1].AddFlowRectangle(column, row);
FlowDocument.ReRenderAll(canvas1);
}
This answer Passing arguments to an event handler would seem to do what I want, but doesn't work as-is because sender
is already defined in this scope. Sadly I don't know enough yet to work around that problem - advice greatly appreciated!