2009-01-23 56 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>