このメソッドをグリッドに追加して、グリッドのセルに配置しようとしています。エラーが発生していると推測しているのは、変換 できないためです。どうすればこれを回避できるかについてのアイデアにprivate void BarCode()
変換できますか?System.Windows.Controls.UIElementCollection
myGrid.Children.Add(BarCode());
あなたのBarCode()
メソッドは返す必要がありますUIElement
BarCode
このように関数を書くことができます
private UIElement BarCode()
{
Image myBarCode = new Image();
myBarCode.Source = new BitmapImage(new Uri("bitmap.png", UriKind.RelativeOrAbsolute));
return myBarCode;
}