I have an application with a Listbox with files and a menu. When I right-click an item from my listbox I have a menu for example Send. When I press ‘Send’ I want another window to open (I already have the new window) and in the new window I want to have the item-path that I selected (I have this path in the main window).
private void MenuItemSend_Click(object sender, RoutedEventArgs e)
{
if (listBoxFiles.SelectedIndex == -1)
{
return;
}
string filePath = (listBoxFiles.SelectedItem).ToString(); --- my file path
StatisticsWindow sForm = new StatisticsWindow();
sForm.ShowDialog(); -- open the new window
}
How can I do it ?
Thanks
Why don’t you create a constructor for the window?
Instead of
this:
You could of course also create a property or a method which handles it, then you can pass it there, e.g.