I'm a beginner in c# wpf and I'm trying to get this code to work, tried to search it but I can't find it.., anyway here's the problem in my code:
Basically im connecting to a database that stores my method names: e.g (window2_open) then after retrieving it, I will create a panel in code behind and add the method name from the dataset:
// row[0].ToString() = window2_open
StackPanel panel = new StackPanel();
panel.AddHandler(StackPanel.MouseDownEvent, new MouseButtonEventHandler(row[0].ToString()));
but i got an error "method name expected", so I looked it up in google and found this:
MouseButtonEventHandler method = (MouseButtonEventHandler) this.GetType().GetMethod(row[0].ToString(), BindingFlags.NonPublic|BindingFlags.Instance).Invoke(this, new object[] {});
but then i get parameter mismatched error, I found that I need to pass the same argument as the function needs, this is my function:
private void window2_open(object sender, RoutedEventArgs e)
{
window2 win2 = new window2();
win2.ShowInTaskbar = false;
win2.Owner = this;
win2.ShowDialog();
}
// where window2 is another xaml
how can I send the same parameter that the function need?