網頁

2016年9月29日 星期四

[ WPF ][ C# ] 介面透明化的方法


如何把介面變成透明呢?



把Window的背景改成#00000000,再把AllowsTransparency="True"。
如果Grid也要變透明就把背景改成#00000000。

如下 xaml 程式表示:
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication1"
        mc:Ignorable="d"
        Title="MainWindow" Height="710.213" Width="867.271" Background="#00000000" AllowsTransparency="True" WindowStyle="None">
    <Grid Margin="0,0,-6.2,-0.6" Background="#00000000">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="137*"/>
            <ColumnDefinition Width="250*"/>
            <ColumnDefinition Width="221*"/>
        </Grid.ColumnDefinitions>
        <TextBox x:Name="textBox" HorizontalAlignment="Left" Height="23" Margin="136,10,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="182" Grid.ColumnSpan="2"/>
        <TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="23" Margin="136,38,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="182" Grid.ColumnSpan="2"/>
        <Button x:Name="button" Content="確定" HorizontalAlignment="Left" Margin="4.8,38,0,0" VerticalAlignment="Top" Width="75" Height="22" RenderTransformOrigin="5.257,0.792" Grid.Column="2"/>
        <Label x:Name="label" HorizontalAlignment="Left" Margin="41,10,0,0" VerticalAlignment="Top" Width="90" Content="名稱"/>
        <Label x:Name="label1" Content="數量" HorizontalAlignment="Left" Margin="41,36,0,0" VerticalAlignment="Top" Width="86"/>
    </Grid>
</Window>

沒有留言:

張貼留言

影片的問題請留在影片的留言區裡。
部落格不會另外通知給我,所以很難發現你有留言。