My problem is that the image that I am setting to my grid is not appearing, the only thing appearing is the black background, so I know the grid is working. I am a noob, and I am very confused. Thanks for the Help :)
Code:
public partial class MainWindow : Window
{
static String ImgNameMole = "C:/Users/MonAmi/Desktop/mole2.png";
public MainWindow()
{
InitializeComponent();
GridMain();
}
private void GridMain()
{
Grid grid_Main = new Grid();
MainWindow1.Content = grid_Main;
grid_Main.Height = 350;
grid_Main.Width = 525;
grid_Main.Background = Brushes.GreenYellow;
CreateImage();
}
private Image CreateImage()
{
Image Mole = new Image();
Mole.Width = 25;
Mole.Height = 25;
ImageSource MoleImage = new BitmapImage(new Uri(ImgNameMole));
Mole.Source = MoleImage;
return Mole;
}
}
Nowhere in your code you are calling
CreateImage()
, so:assuming that you have added at least one row and one column to your grid.