Iam trying to change the image of the MainWindow's Grid, which is a room with no lights, by pressing a button on another Window, and come up with a room with lights background. The problem is that when i edit the onClick event of the button i cant change the MainWindow's Grid Background.
XAML of MainWindow's Grid:
<Grid x:Name="PIC">
<Grid.Background>
<ImageBrush ImageSource="lightsofflaptop.jpg"/>
</Grid.Background>
And the Window's Code:
public partial class Window3 : Window
{
public Window3()
{
InitializeComponent();
}
private void button_Click(object sender, RoutedEventArgs e)
{
ImageBrush b1 = new ImageBrush();
b1.ImageSource = new BitmapImage(new Uri(@"---\lightsonNOlaptop.jpg"));
}
}
i cant connect b1 with the Grid Background of the MainWindow.
Thanks in advance.
**Edit
I navigate through Windows by this:
*button located in MainWindow.cs
private void button_Click(object sender, RoutedEventArgs e)
{
var newForm = new Window1();
newForm.Show();
this.Close();
}