2009-01-23 57 views
7

我正在做我的第一次进入WPF - 我有一个简单的窗体与弹出定义的内嵌帮助。我正在使用圆角,出于某种原因,黑色背景正在流过角落。我不明白哪个元素导致问题。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> 

回答

24

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

Popup.AllowsTransparency

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

+0

是做到了,谢谢! – Jason 2009-01-23 20:49:03

0

您也可以将弹出包装在具有圆角的边框中。如果您不能更改弹出窗口的AllowsTransparency,这很有用。

事情是这样的:

<Border CornerRadius="10"> 
    <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> 
</Border>