WPF中,設置AllowsTransparency=true去除邊框的方法比較簡單,這裏不做詳細說明。下面主要演示AllowsTransparency=false的時候去除邊框的方法。
1.去網上下載一個Microsoft.Windows.Shell.dll
2.添加引用
xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
3.設置相關屬性
<Setter Property="shell:WindowChrome.WindowChrome">
<Setter.Value>
<shell:WindowChrome CaptionHeight="0"
CornerRadius="0"
GlassFrameThickness="0"
NonClientFrameEdges="None"
ResizeBorderThickness="5" />
</Setter.Value>
</Setter>
4.運行即可看到你想要的效果。
5.這裏我添加的是一個COM組件,若是設置AllowsTransparency=true,改COM組件在運行期不可見。因此我們需要新的方法來去除邊框,既能去掉邊框,也能加載COM組件,何樂而不爲~~~