使窗口透明,您可以將GlassFrameThickness設爲-1。下面的樣式添加到您的窗口。
<Window.Style>
<Style TargetType="Window">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome GlassFrameThickness="-1"/>
</Setter.Value>
</Setter>
</Style>
</Window.Style>
如果我理解正確,你也想隱藏窗口按鈕(最小,最大,關閉),然後創建下列WindowsExtension並註冊到SourceInitialized事件
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
SourceInitialized += (x, y) => this.HideWindowButtons();
}
}
internal static class WindowExtensions
{
private const int GWL_STYLE = -16;
private const int WIN_MAXIMIZE = 0x10000;
private const int WIN_MINIMIZE = 0x20000;
private const int WIN_CLOSE = 0x80000;
[DllImport("user32.dll")]
extern private static int GetWindowLong(IntPtr hwnd, int index);
[DllImport("user32.dll")]
extern private static int SetWindowLong(IntPtr hwnd, int index, int value);
internal static void HideWindowButtons(this Window window)
{
var hwnd = new System.Windows.Interop.WindowInteropHelper(window).Handle;
var currentStyle = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, (currentStyle & ~WIN_MINIMIZE & ~WIN_MAXIMIZE & ~WIN_CLOSE));
}
}
我希望我能記住我在哪裏找到了這個擴展示例,以便給這個傢伙一些信用。如果您打算覆蓋控制模板以添加較粗的邊框,則它看起來像是一個CornerRadius 8,以匹配航空邊框。無論如何,這應該讓你開始。希望那是你以後的樣子。