WPF 圆角背景渗出 [英] WPF Rounded Corners background bleeding through

查看:51
本文介绍了WPF 圆角背景渗出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm making my first foray into WPF - I have a simple form with a popup defined for inline help. I'm using rounded corners, and for some reason a black background is bleeding through around the corners. I don't understand which element is causing the problem.

替代文字 http://www.awbrey.net/rounded.jpg

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

I assume it's something blindingly obvious which I'm just not seeing. Here's the XAML I'm using:

<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>

推荐答案

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

I think it is the Popup that is causing the problem. Try setting AllowsTransparency to True on the popup.

Popup.AllowsTransparency

当设置为 False 时,任何透明颜色都会与黑色合并".

When set to False, any transparent colors are "merged" with black.

这篇关于WPF 圆角背景渗出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆