I have a problem with adding parameters to EventHandler.
I have a control when user select message and choose to who he want to send it.
I need to handler OnConfirmForwarClosed add in some way variable item.
How can I do it?
private void inboxContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
var item = (RadMenuItem)e.Source;
RadWindow.Confirm("Do you want forward this message to item.DataContext.HandlerName ?", OnConfirmForwarClosed);
}
private void OnConfirmForwarClosed(object sender, WindowClosedEventArgs e)
{
if (e.DialogResult == true)
{
//here I need item from caller
}
}
EDIT
I need a result which I can get by this solution:
RadWindow.Confirm("Do you want forward this message to item.DataContext.HandlerName ?",(s,ea)=>
{
if(ea.DialogResult==true)
{
MessageBox.Show((item.DataContext as Handler).HandlerId.ToString());
}
});
If i understand your question correctly, you don’t want to “lift” the local variable into lambda, such as…
…and instead you want to keep the
OnConfirmForwarClosed(presumably to subscribe to events not shown here). If that’s correct, then you have couple of options:1.
You could just arrange your methods differently:
2.
Set the object field:
3.
Co-opt one of the existing
OnConfirmForwarClosedparameters:Etc, etc…