[英]Is it possible to Host a WPF Page in HwndHost?
First of all this might feel as a stupid Question (You could have loaded WPF content directly in a WPF window), but actually read the full description to know why I need this.首先,这可能是一个愚蠢的问题(您可以直接在 WPF 窗口中加载 WPF 内容),但实际上阅读完整描述以了解我为什么需要这个。
I am developing a C# WPF Application to Emulate Windows Acrylic Blur Effect.我正在开发一个 C# WPF 应用程序来模拟 Windows 丙烯酸模糊效果。 I am using sample code from here: Win32 Composition Samples .
我正在使用此处的示例代码: Win32 Composition Samples 。
With this code I was able to create the acrylic blur on an HwndHost
or Directly on the Window.使用此代码,我能够在
HwndHost
上或直接在 Window 上创建丙烯酸模糊。 But this causes the Windows Aerospace Issue which means all the controls I draw on the window will appear under the AcrylicBlur (Blurred).但这会导致 Windows 航空航天问题,这意味着我在 window 上绘制的所有控件都将出现在 AcrylicBlur(模糊)下。 Like this one:
像这个:
Acrylic Content Overlapping My WPF Button亚克力内容重叠我的 WPF 按钮
So I decided to create a window with acrylic effect and create a HwndHost
as the child of that window so that I could overlap the WPF Content on top of the Acrylic Blur so that the WPF Controls Won't Get Blurred Out. So I decided to create a window with acrylic effect and create a
HwndHost
as the child of that window so that I could overlap the WPF Content on top of the Acrylic Blur so that the WPF Controls Won't Get Blurred Out.
There is One more Concept that I can try out, is to create two windows one with the acrylic and one with the WPF and share there WM_POSITIONCHANGED
Message for both window which cause the windows to move and resize equally. There is One more Concept that I can try out, is to create two windows one with the acrylic and one with the WPF and share there
WM_POSITIONCHANGED
Message for both window which cause the windows to move and resize equally. But this have several issues.但这有几个问题。
Find a way to Host WPF Page, instead of using HwndHost i used HwndSource.找到一种方法来托管 WPF 页面,而不是使用 HwndHost,我使用了 HwndSource。
HwndSourceParameters param = new HwndSourceParameters("Host");
param.PositionX = 10;
param.PositionY = 10;
param.Width = 500;
param.Height = 500;
param.ExtendedWindowStyle +=0x00200000; //This style creates a transparent window
param.WindowStyle = 0x10000000;
HwndSource src = new HwndSource(param);
src.SizeToContent = SizeToContent.WidthAndHeight;
src.CompositionTarget.BackgroundColor = Colors.Transparent;
src.RootVisual = new Page1(); //Your Page Here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.