user2122032
user2122032

Reputation: 81

The best overloaded method match for 'System.Windows.Controls.UIElementCollection.Add(System.Windows.UIElement)' has some invalid arguments

I am trying to add this method to the grid and place it in a cell in the grid. Im guessing the error is im getting is because I cant convert: private void BarCode() into the System.Windows.Controls.UIElementCollection any ideas on how can I get around this?

myGrid.Children.Add(BarCode());

Upvotes: 0

Views: 686

Answers (2)

Arsalan Ahmad
Arsalan Ahmad

Reputation: 688

You can write your BarCode function like this

private UIElement BarCode()
{
    Image myBarCode = new Image();
    myBarCode.Source = new BitmapImage(new Uri("bitmap.png", UriKind.RelativeOrAbsolute));
    return myBarCode;
}

Upvotes: 0

Guru Stron
Guru Stron

Reputation: 142833

your BarCode() method needs to return UIElement

Upvotes: 1

Related Questions