I know it has been asked before but after about an hour of searching I am unable to figure out the simplest and easiest way to add a parameter to an event handler. By default, the template for these handlers can only accept (object sender, RoutedEventArgs e) arguments. I find it hard to believe that there isn't a clean and easy way to do this because I imagine this problem occurs quite frequently. However I am new to WPF so if someone could provide some guidance on this issue my code is below.
When clicking on this button
<Button Height="23" VerticalAlignment="Bottom" Margin="150, 0, 0, 2" Content="Terminate All Processes" Width="135" HorizontalAlignment="Left" Click="TerminateAll_Click" Name="TerminateAll"/>
I need an event to fire off that closes all my processes. To do this though, i need to pass the list of all the processes to the event handler and I have yet to discover an easy way of doing this. Thank you for any help you can provide.
Edit: This is my .cs file
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ObservableCollection<Proc> procs = new ObservableCollection<Proc>();
Processes.getProcs(ref procs);
lview.ItemsSource = procs;
}
private void TerminateAllProcesses(ObservableCollection<Proc> procs)
{
foreach (Proc p in procs)
{
if (!p.Pro.HasExited) { p.Pro.Kill(); }
}
}
public void TerminateAll_Click(object sender, RoutedEventArgs e)
{
}
}
Clickevent?