WPF窗口左上角不透明

时间:2019-01-19 23:12:38

标签: c# wpf visual-studio-2008 .net-3.5 borderless

我在WPF下有无边框窗口:

<Window x:Class="MyAPP.WMainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:system="clr-namespace:System;assembly=mscorlib"   
        Height="620" Width="800" 
        WindowStyle="None"
        AllowsTransparency="True"
        ResizeMode="CanResizeWithGrip">

<Window.Resources>
    <Style x:Key="WindowIconStyle"
       TargetType="{x:Type Hyperlink}">
        <Setter Property="FontFamily"
            Value="Webdings" />
        <Setter Property="FontSize"
            Value="16" />
        <Setter Property="Foreground"
            Value="Black" />
        <Setter Property="TextBlock.TextDecorations"
            Value="{x:Null}" />
        <Setter Property="Cursor"
            Value="{x:Null}" />            
        <Style.Triggers>
            <Trigger Property="IsMouseOver"
                 Value="True">
                <Setter Property="Foreground"
                    Value="#ED5326" />
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>

<Border BorderBrush="SkyBlue" BorderThickness="2" CornerRadius="20 0 0 0">
    <DockPanel>
    <Border x:Name="WindowTitleBar"  
                DockPanel.Dock="Top"
                CornerRadius="20 0 0 0"                                        
                Background="LightBlue">




            <StatusBar DockPanel.Dock="Top"  Background="Transparent" 
                       MouseDoubleClick="TriggerMaximize"
                       MouseMove="TriggerMoveWindow">

                <StatusBarItem DockPanel.Dock="Right">  
                    <TextBlock Margin="5"
                               VerticalAlignment="Center">
                        <Hyperlink Click="TriggerClose"
                                   Style="{StaticResource WindowIconStyle}">r                                
                        </Hyperlink>
                    </TextBlock>
                </StatusBarItem>

                <StatusBarItem DockPanel.Dock="Right">
                    <TextBlock Margin="5"
                               VerticalAlignment="Center">
                        <Hyperlink Click="TriggerMaximize" 
                                   Style="{StaticResource WindowIconStyle}">2
                        </Hyperlink>
                    </TextBlock>
                </StatusBarItem>

                <StatusBarItem  DockPanel.Dock="Right">
                    <TextBlock  Margin="5"
                               VerticalAlignment="Center">
                        <Hyperlink Click="TriggerMinimize"
                                   Style="{StaticResource WindowIconStyle}">0
                        </Hyperlink>
                    </TextBlock>
                </StatusBarItem>

                <StatusBarItem HorizontalAlignment="Center">
                    <TextBlock x:Name="WindowTitle" VerticalAlignment="Center" 
                               Foreground="Black" 
                               FontSize="16"/>
                </StatusBarItem>

            </StatusBar>


    </Border>
    <Grid>
         <!-- Grid Stuff -->
    </Grid>
 </DockPanel>
</Border>

如上所示,我已放置边框作为主窗口内容,以便应用自定义角半径“ 20 0 0 0”,也就是说,我已将窗口左上角四舍五入,但它不是透明的,请参见下图:

enter image description here

1 个答案:

答案 0 :(得分:1)

将窗口的背景设置为1200px x 1000px