title: How To Change Grid Opacity using Slider Value In C#
body: <p>I want to change or control grid or something like image or any opacity using slider value.
  I got full window control program but I failed to change grid opacity.</p>
  
  <p><strong>See this code for changing window opacity.</strong></p>
  
  <pre><code> public partial class MainWindow : MetroWindow
      {
          public MainWindow()
          {
              InitializeComponent();
              this.AllowsTransparency = true;
          }
  
          private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
          {
              this.Opacity = slider.Value / 100;
  
          }
  }
  </code></pre>
  
  <p>And see result:
  <a href="https://i.stack.imgur.com/KzGa8.png" rel="nofollow noreferrer">Its worked perfectly</a></p>
  
  <p>But I want to change grid (image/rectangle or something) opacity via slider value.
  I also tried by this code but not working:</p>
  
  <pre><code> private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e)
                  {              
                    mygrid.Opacity =slider.Value / 100;
                  }
  </code></pre>