title: Borderless window Drop shadow Opacity elements issue
body: <p>I am trying to create a borderless window in WPF. I am using the class mentioned in the <a href="https://stackoverflow.com/questions/3372303/dropshadow-for-wpf-borderless-window">link</a>.</p>
  
  <p>This works fine as long as all elements are all enabled (Opacity = 1). if i set opacity to 0.5, it is almost invisible.</p>
  
  <p>The opacity works fine if i remove the code for the drop shadow. I am not sure what is the cause of this.</p>
  
  <p>The class is the same one i am using as explained in link above. The rest of my code is below. </p>
  
  <p>Any help is appreciated :</p>
  
  <ul>
  <li>Girija</li>
  </ul>
  
  <p>XAML:</p>
  
  <pre><code>&lt;Window x:Class="Sample.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:Sample"&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="70"/&gt;
          &lt;RowDefinition Height="*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;TextBox Margin="2" Text="Something" Grid.Row="0"/&gt;
      &lt;Button Grid.Row="1" Content="Something" IsEnabled="False" Opacity="0.7"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>Code behind :</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Interaction logic for Window1.xaml
  /// &lt;/summary&gt;
  public partial class Window1 : Window
  {
  
      public Window1()
      {
          InitializeComponent();
  
      }
  
      /// &lt;summary&gt;
      /// Raises the &lt;see cref="E:System.Windows.FrameworkElement.Initialized"/&gt; event. 
      /// This method is invoked whenever 
      /// &lt;see cref="P:System.Windows.FrameworkElement.IsInitialized"/&gt; is set to true internally.
      /// &lt;/summary&gt;
      /// &lt;param name="e"&gt;The &lt;see cref="T:System.Windows.RoutedEventArgs"/&gt; 
      /// that contains the event data.&lt;/param&gt;
      protected override void OnInitialized(EventArgs e)
      {
          //AllowsTransparency = false;
          ResizeMode = ResizeMode.NoResize;
  
          WindowStartupLocation = WindowStartupLocation.CenterScreen;
          WindowStyle = WindowStyle.None;
  
          DwmDropShadow.DropShadowToWindow(this);
  
          base.OnInitialized(e);
      }
  }
  </code></pre>
  
  <p>helper Class taken from above link :</p>
  
  <pre><code>class DwmDropShadow 
  </code></pre>
  
  <p>{ </p>
  
  <pre><code>[DllImport("dwmapi.dll", PreserveSig = true)] 
  private static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize); 
  
  [DllImport("dwmapi.dll")] 
  private static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref Margins pMarInset); 
  
  /// &lt;summary&gt; 
  /// Drops a standard shadow to a WPF Window, even if the window isborderless. Only works with DWM (Vista and Seven). 
  /// This method is much more efficient than setting AllowsTransparency to true and using the DropShadow effect, 
  /// as AllowsTransparency involves a huge permormance issue (hardware acceleration is turned off for all the window). 
  /// &lt;/summary&gt; 
  /// &lt;param name="window"&gt;Window to which the shadow will be applied&lt;/param&gt; 
  public static void DropShadowToWindow(Window window) 
  { 
      if (!DropShadow(window)) 
      { 
          window.SourceInitialized += new EventHandler(window_SourceInitialized); 
      } 
  } 
  
  private static void window_SourceInitialized(object sender, EventArgs e) 
  { 
      Window window = (Window)sender; 
  
      DropShadow(window); 
  
      window.SourceInitialized -= new EventHandler(window_SourceInitialized); 
  } 
  
  /// &lt;summary&gt; 
  /// The actual method that makes API calls to drop the shadow to the window 
  /// &lt;/summary&gt; 
  /// &lt;param name="window"&gt;Window to which the shadow will be applied&lt;/param&gt; 
  /// &lt;returns&gt;True if the method succeeded, false if not&lt;/returns&gt; 
  private static bool DropShadow(Window window) 
  { 
      try 
      { 
          WindowInteropHelper helper = new WindowInteropHelper(window); 
          int val = 2; 
          int ret1 = DwmSetWindowAttribute(helper.Handle, 2, ref val, 4); 
  
          if (ret1 == 0) 
          { 
              Margins m = new Margins { Bottom = 0, Left = 0, Right = 0, Top = 0 }; 
              int ret2 = DwmExtendFrameIntoClientArea(helper.Handle, ref m); 
              return ret2 == 0; 
          } 
          else 
          { 
              return false; 
          } 
      } 
      catch (Exception ex) 
      { 
          // Probably dwmapi.dll not found (incompatible OS) 
          return false; 
      } 
  } 
  </code></pre>
  
  <p>} </p>