user3157821
user3157821

Reputation: 119

Button method error?

I create a view, save the XAML into a file and want to open the file up that I select from a combobox.

public MainWindow2(string name)
{
        InitializeComponent();
        cmbnames.Items.Add(name);
        string choice = cmbnames.SelectedItem.ToString();
}

private void Button_Click_1(object sender, EventArgs e, string choice)
{
        using (var fs = File.Open(choice, FileMode.Open))
        {
            stacky1.Children.Add((UIElement)XamlReader.Load(fs));
        }
}

I am trying to select an item from a ComboBox and then when I click load it should find the file and load up that XAML.

But for some reason I get an error saying:

No overload for 'Button_Click_1' matches delegate 'System.Windows.RoutedEventHandler'

Upvotes: 0

Views: 92

Answers (1)

Nagaraj S
Nagaraj S

Reputation: 13484

change your private void Button_Click_1(object sender, EventArgs e, string choice)

Use this

 private void Button1_Click(object sender, System.EventArgs e)

Upvotes: 1

Related Questions