title: Code to change button color isn't working
body: <p>I have some code for changing a button color within the button click function itself that works just fine.</p>
  
  <pre><code>_5.Background = new SolidColorBrush(Color.FromArgb(50, 180, 20, 30));
  </code></pre>
  
  <p>But when I try to call _5 from another form using an object reference, nothing happens despite it compiling correctly.</p>
  
  <pre><code>private void Button_Click_1(object sender, RoutedEventArgs e)
          {           
              MainWindow b = new MainWindow();
              b._5.Background = new SolidColorBrush(Color.FromArgb(50, 180, 20, 30));
          }
  </code></pre>
  
  <p>Can someone point out what I'm doing incorrectly please?</p>
  
  <p>Thank you.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  
  
  
  namespace SBI_Mgt_System
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
  
          public MainWindow()
          {
              InitializeComponent();
          }
  
          public void _1_Click(object sender, RoutedEventArgs e)
          {            
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();
          }
  
          public void Button_Click(object sender, RoutedEventArgs e)
          {
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();
          }
  
          public void Button_Click_1(object sender, RoutedEventArgs e)
          {
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();
          }
  
          public void Button_Click_2(object sender, RoutedEventArgs e)
          {
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();
          }
  
          public void Button_Click_3(object sender, RoutedEventArgs e)
          {
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();
          }
  
          public void Button_Click_4(object sender, RoutedEventArgs e)
          {
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();
          }
  
          public void Button_Click_5(object sender, RoutedEventArgs e)
          {
              Room1 openRoom = new Room1();
              openRoom.Show();
              rooms x = new rooms();
              x.Show();              
          }
     }
  }
  </code></pre>
  
  <p>The other form...</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Data;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Shapes;
  
  namespace SBI_Mgt_System
  {
      /// &lt;summary&gt;
      /// Interaction logic for rooms.xaml
      /// &lt;/summary&gt;
  
      public partial class rooms : Window
      {
          public static bool res = false;
  
          public rooms()
          {
              InitializeComponent();    
  
          }
  
  
          private void Button_Click(object sender, RoutedEventArgs e)
          {
  
              this.Close();
          }
  
          private void Button_Click_1(object sender, RoutedEventArgs e)
          {           
              MainWindow b = new MainWindow();
              b._5.Background = new SolidColorBrush(Color.FromArgb(50, 180, 20, 30));
          }
      }
  }
  </code></pre>