Sub EnableBlur()
Dim windowHelper As New WindowInteropHelper(Me)
Dim accent As New AccentPolicy()
Dim accentStructSize = Marshal.SizeOf(accent)
accent.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND
Dim accentPtr = Marshal.AllocHGlobal(accentStructSize)
Marshal.StructureToPtr(accent, accentPtr, False)
Dim data As New WindowsCompostionAttributeData() With {
.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
.SizeOfData = accentStructSize,
.Data = accentPtr
}
SetWindowCompositionAttribute(windowHelper.Handle, data)
Marshal.FreeHGlobal(accentPtr)
End Sub
定义一个sub过程
然后在窗口的loaded事件里调用EnableBlur()
就可以啦