WPF 圆角背景渗出

标签 wpf xaml rounded-corners

我第一次涉足 WPF - 我有一个简单的表单,其中包含一个为内联帮助定义的弹出窗口。我正在使用圆角,由于某种原因,黑色背景在角落里渗出。我不明白是哪个元素导致了问题。

alt text http://www.awbrey.net/rounded.jpg

我认为这是我没有看到的非常明显的东西。这是我正在使用的 XAML:

<Window x:Class="Consent.Client.SubjectNumberEntry"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" FontSize="24"
    Title="SubjectNumberEntry" WindowStyle="None" WindowState="Maximized"
        xmlns:h="clr-namespace:Consent.Client" KeyDown="windowOuter_KeyDown" Background="White" Name="windowOuter" AllowsTransparency="true" Loaded="Window_Loaded">

    <StackPanel Height="400" DockPanel.Dock="Top" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10">
        <StackPanel Height="60" Orientation="Horizontal" VerticalAlignment="Center">
            <TextBox Name="txtSubjectNumber" Margin="10" Width="400" KeyDown="txtSubjectNumber_KeyDown" h:HelpProvider.HelpString="Enter the subject identifier, or scan their wristband">
                <TextBox.ToolTip>This is a textbox</TextBox.ToolTip>
            </TextBox>
            <Button Name="btnEnter" Margin="10" Width="100" Click="btnEnter_Click">Enter</Button>
            <Button Width="50" Name="btnHelp" Margin="10" Click="btnHelp_Click">?</Button>
            <Button Width="50" Name="btnExit" Margin="10" Click="btnExit_Click">Exit</Button>


        </StackPanel>
        <Label Name="lblValue" Margin="10"></Label>


        <Popup Placement="Bottom" HorizontalAlignment="Center" VerticalOffset="10" MouseDown="popHelp_MouseDown" PopupAnimation="Fade" Name="popHelp" PlacementTarget="{Binding ElementName=txtSubjectNumber}">
            <Border Padding="10" Margin="10" BorderBrush="CornflowerBlue" BorderThickness="1" CornerRadius="10" Background="CornflowerBlue">
                <TextBlock FontSize="12" Background="CornflowerBlue">This is the content of the help box.</TextBlock>
            </Border>
        </Popup>

    </StackPanel>


</Window>

最佳答案

我认为是导致问题的弹出窗口。尝试在弹出窗口中将 AllowsTransparency 设置为 True。

Popup.AllowsTransparency

当设置为 False 时,任何透明颜色都将与黑色“合并”。

关于WPF 圆角背景渗出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/474204/

相关文章:

wpf - 如何使用转换器绑定(bind)到静态资源?

android自定义searchView圆角

c# - 当节点展开或折叠时,如何更改 WPF TreeView 中节点的图像?

c# - 如何将 Html 转换为 UWP 的 Xaml

wpf - 准备好 Dialog ViewModel 绑定(bind),调用 Dialog 并在 MVVM 中从中返回数据

c# - 调整选定的 ListViewItem TextBlock 样式

python - 有什么方法可以在 python 中为图像制作漂亮的抗锯齿圆角?

ios - UIView 带有圆角和阴影?

c# - 使用 MVVM WPF 将数据保存到 Collection 和 Display

wpf - 如何在资源字典中使用引用转换器