title: Overriding a WPF window style in a Prism module
body: <p>I'm writing a module for a prism application that we do not control. The requirement is to show a web browser control in one of the regions. Unfortunately, each window derives from a CustomWindow class, that has <code>AllowsTransparency=true</code>. Having <code>AllowTransparency=true</code> prevents the WebBrowser control from displaying.</p>
  
  <p>I can right click and hover over the control and know there is a web page loaded (google), so I'm nearly certain that the problem I'm facing has to do with transparency and win32 controls (of which the WebBrowser is a wrapped win32 control to my knowledge).</p>
  
  <p>So, I've decided that my only course of action is to try and override the Window style, to turn AllowTransparency off.</p>
  
  <p>This is the offending style (using Reflector to browse the baml):</p>
  
  <pre><code>&lt;Style x:Key="{x:Type local:CustomWindow}" TargetType="{x:Type local:CustomWindow}"&gt;
      &lt;Setter Property="AllowsTransparency" Value="true" /&gt;
      ...
  &lt;/Style&gt;
  </code></pre>
  
  <p>And this is how I'm trying to remove the style:</p>
  
  <pre><code>&lt;ResourceDictionary 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:Controls="clr-namespace:Vendor.App.WPFCommon.Controls;assembly=Vendor.App.WPFCommon"&gt;
      &lt;Style TargetType="{x:Type Controls:CustomWindow}"&gt;
          &lt;Setter Property="AllowsTransparency" Value="false" /&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  
  
  <pre><code>private void LoadThemeOverrides()
  {
      var assemblyName = System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().ManifestModule.Name);
      var overrides = new Uri(string.Format("{0};component/themes/overrides.xaml", assemblyName), UriKind.Relative);
      var themeManager = _container.Resolve&lt;IThemeManager&gt;();
      foreach (var theme in themeManager.ThemeCollection)
          theme.Sources.Add(overrides);
      var rd = new ResourceDictionary {Source = overrides};
      Application.Current.Resources.MergedDictionaries.Add(rd);
      themeManager.ChangeTheme(themeManager.CurrentTheme);
  }
  </code></pre>
  
  <p>The ResourceDictionary is being loaded correctly, so it's not the URI that is the problem. I debugged the <code>rd</code>, and I can see my style in there.</p>
  
  <p>The above piece of code is run between the login window validating user/password, and the main application window being displayed. They are two different windows, however, they both derive from CustomWindow.</p>
  
  <p>Using WPF Inspector, I can see that the CustomWindows still have AllowTransparency set to true. Am I able to override this style at all? Or am I attempting to do this incorrectly?</p>