ねえ、私はC#に慣れていません。私はコードを私はアプリケーションランチャーを作ろうとしていると私は最後にRoutedEventHandlerメソッド呼び出しに余分な引数を渡そうとしているが、それは私にエラーを与えると思う、私はグーグルでそれを探してみましたが、 。 (私はnoobの午前)ので、ここであなたがRoutedEventHandlerのメソッドシグネチャを変更することはできません外観とit.ThanksC#で新しいRoutedEventHandler menthodに引数を渡すにはどうすればよいですか?
namespace Button_Launcher
{
public partial class MainWindow : Window
{
private string line;
public MainWindow()
{
InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog fileName = new OpenFileDialog();
fileName.Filter = "executables (.exe)|*.exe";
fileName.ShowDialog();
StreamWriter writer = new StreamWriter("E:/Config.txt",true);
writer.WriteLine(fileName.FileName);
writer.Close();
textBox.Text = fileName.FileName;
}
private void button1_Click(object sender, RoutedEventArgs e)
{
string file = ("E:/Config.txt");
StreamReader Reader = new StreamReader(file, Encoding.ASCII);
List<string> appList = new List<string>();
List<string> Items = new List<string>();
int count = 1;
while ((line = Reader.ReadLine()) != null)
{
makeButton(line,count);
count++;
}
Reader.Close();
}
public void makeButton(string link,int count)
{
string[] mySplit = link.Split(new char[] { '\\' });
string[] name = mySplit.Last().Split(new char[] { '.' });
string fName = name.First();
string buttonName = fName;
Button newBtn = new Button();
newBtn.Content = buttonName;
newBtn.Height = 30;
newBtn.Width = 70;
newBtn.Margin = new Thickness(-60, 90*count/1.5, 180,80);
StackPanel sp = new StackPanel();
sp.Children.Add(newBtn);
mainGrid.Children.Add(sp);
newBtn.Click += new RoutedEventHandler(launchApp(link));
//launchApp(link);
}
private void launchApp(string link,object sender, RoutedEventArgs e)
{
Process.Start(link);
}
}
}
メソッドのシグネチャを変更したためです。ここを回避することができますhttp://stackoverflow.com/a/8109471/4767498 –