우리가 제어하지 않는 프리즘 응용 프로그램 용 모듈을 작성하고 있습니다. 요구 사항은 지역 중 하나에서 웹 브라우저 컨트롤을 표시하는 것입니다. 아쉽게도 각 창은 AllowsTransparency=true
인 CustomWindow 클래스에서 파생됩니다. AllowTransparency=true
을 지정하면 WebBrowser 컨트롤이 표시되지 않습니다.프리즘 모듈에서 WPF 윈도우 스타일 재정의
마우스 오른쪽 버튼을 클릭하여 컨트롤 위에 마우스를 올리면 (google)로드 된 웹 페이지가 있음을 알 수 있으므로 내가 당면한 문제는 투명성과 win32 컨트롤과 관련이 있습니다. WebBrowser는 필자의 지식에 따라 Win32 컨트롤을 사용합니다.)
내 유일한 조치는 AllowTransparency를 끄기 위해 Window 스타일을 무시하고 재정의하는 것입니다.
이
은 잘못된합니다 (BAML을 찾아 리플렉터를 사용) 스타일 :<Style x:Key="{x:Type local:CustomWindow}" TargetType="{x:Type local:CustomWindow}">
<Setter Property="AllowsTransparency" Value="true" />
...
</Style>
그리고 이것은 내가 스타일을 제거하기 위해 노력하고있어 방법은 다음과 같습니다
<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">
<Style TargetType="{x:Type Controls:CustomWindow}">
<Setter Property="AllowsTransparency" Value="false" />
</Style>
</ResourceDictionary>
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<IThemeManager>();
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);
}
을 ResourceDictionary가 올바르게로드되어 문제가되는 URI가 아닙니다. 나는 rd
을 디버깅했고 거기에 내 스타일을 볼 수 있습니다.
위의 코드는 사용자/암호 유효성 검사 로그인 창과 표시되는 주 응용 프로그램 창 사이에서 실행됩니다. 두 개의 다른 창이지만 CustomWindow에서 파생됩니다.
WPF Inspector를 사용하면 CustomWindows가 여전히 AllowTransparency를 true로 설정 한 것을 볼 수 있습니다. 이 스타일을 전혀 무시할 수 있습니까? 아니면이 작업을 잘못 수행하려고합니까?
'ResourceKey'를 사용하여 무슨 뜻인지 설명해 주시겠습니까? google-foo가 많은 WPF를 배우고 있습니다. –
"