<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="wfaa.MainWindow"
x:Name="Window"
Title="wLogin"
Width="360" Height="260" WindowStyle="none" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Background="Transparent">
<Grid x:Name="LayoutRoot" Margin="0,0,0,0" Background="white">
<Grid.RowDefinitions>
<RowDefinition Height="112*" />
<RowDefinition Height="34*" />
<RowDefinition Height="34*" />
<RowDefinition Height="41*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="118*" />
<ColumnDefinition Width="220*" />
</Grid.ColumnDefinitions>
<TextBox Background="Transparent" Grid.Row="1" Height="25" HorizontalAlignment="Left" Margin="74,0,0,0" Name="textBox1" VerticalAlignment="Top" Width="164" Grid.ColumnSpan="2" />
<PasswordBox Background="Transparent" Grid.Row="2" Height="23" HorizontalAlignment="Left" Margin="74,0,0,0" Name="passwordBox1" VerticalAlignment="Top" Width="164" Grid.ColumnSpan="2" />
<TextBlock Height="47" HorizontalAlignment="Left" Margin="74,46,0,0" Name="textBlock1" Text="Hello" VerticalAlignment="Top" Width="133" FontSize="26" Grid.ColumnSpan="2" FontWeight="Bold" />
</Grid>
</Window>
win7下:
winXP下:
AllowsTransparency 是设置窗口透明的,你要的textbox不遮挡后面的内容的话,设置textbox的属性 :Background="Transparent" 即可。
是我没描述好。你误会我的意思了。这个textBox是放在grid里面的。grid的背景是白色的。在win7上可以显示全部样式。可是在winxp(虚拟机)上,整个窗体就只显示一个textBox。我重新截两个图,你帮我看看。
@ChenYa.Liu:
我试了一下,在xp下也可以透明的,但你的例子中把最底部的grid背景设置为white,在xp和win7下应该都是白色背景才对,应该把背景色也设置为透明。