你好WPF愛好者。 隨着WPF等統一API語言的發明,豐富用戶界面變得很是容易。 建立豐富的用戶界面只是一個想法。 您須要擁有的是創造性思惟和最新技術融合。 WPF和Expression Blend在製做豐富的UI應用程序,清晰的圖形和很是好的動畫方面很是有用。windows
我將要發佈的是將窗口矩形形狀塑形成圖像的形狀。 它能夠是任何圖像,任何形狀,任何大小,它應該是沒有背景的PNG(便攜式網絡圖形)圖像(白色背景被移除)。網絡
嗯,實現這一點是小菜一碟,但我仍然會提供一個完整的演練過程。app
如今咱們的圖像文件準備就緒,讓咱們如今塑造咱們的WPF表格。工具
<window title="ShapedWindow" windowstartuplocation="CenterScreen" allowstransparency="True" opacitymask="White" windowstyle="None" background="Transparent" width="620" height="267" xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation x:class="ShapedWPFForm.ShapedWindow"> <grid> <img name="imgBackground" source="Shape.png" stretch="Fill" /> </grid> </window>
全部就完成了動畫
XAML屬性解釋:spa
allowstransparency="True"
- 設置窗體透明度。background="Transparent"
- 代表背景是透明的。windowstyle="None"
- 此屬性刪除標題欄並使窗體無邊框。 基本上從窗體中刪除全部系統控件。opacitymask="White"
- 此屬性使指定的背景顏色不受窗體的影響。完成,教程完成。 經過這樣作,您能夠將圖像做爲窗體形狀。 爲您的窗體賦予創意。點擊下載自定義WPF窗體形狀源代碼下載
code