生活随笔
收集整理的這篇文章主要介紹了
WPR-007:WPF中窗体的透明设置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一般使用WindowStyle=,Background=,AllowsTransparency,Opacity來進行設置。
1、設置Opacity控制整個窗口的透明,包括上面的控件
Window x:Class="TestTransparentWindow.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="441" Width="870" WindowStyle="None" AllowsTransparency="True" Opacity="0.5"> <Grid Width="500" Height="300" Background="Black"> </Grid> </Window>
2、窗體空白部分全部透明,控件部分顯示顏色
這種可是使用自定義的控件形狀,來使窗體呈現自定義的形狀
<Window x:Class="TestTransparentWindow.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="441" Width="870" WindowStyle="None" AllowsTransparency="True" Background="#00FFFFFF"> <Grid Width="500" Height="300" Background="Black"> </Grid> </Window>
3、空白部分半透明,控件部分不透明
依然使用Background設置顏色
<Window x:Class="TestTransparentWindow.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="441" Width="870" WindowStyle="None" AllowsTransparency="True" Background="#AA000000"> <Grid Width="500" Height="300" Background="Black"> </Grid> </Window>
工程代碼下載:http://download.csdn.net/detail/yysyangyangyangshan/5096470
?
轉載于:https://blog.51cto.com/yangyoushan/1276422
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎
總結
以上是生活随笔為你收集整理的WPR-007:WPF中窗体的透明设置的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。