WPF窗口左上角不透明
Posted
技术标签:
【中文标题】WPF窗口左上角不透明【英文标题】:WPF Window top left corner not being transparent 【发布时间】:2019-06-13 19:00:49 【问题描述】:我有下面的 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”,也就是说,我已将窗口左上角变圆但它不透明,请参阅下图:
【问题讨论】:
【参考方案1】:将窗口的背景设置为Transparent
。
【讨论】:
对!我忘记设置了。谢谢!以上是关于WPF窗口左上角不透明的主要内容,如果未能解决你的问题,请参考以下文章