2009-01-23 6 views
7

Je fais ma première incursion dans WPF - J'ai un formulaire simple avec un popup défini pour l'aide en ligne. J'utilise des coins arrondis, et pour une raison quelconque, un fond noir saigne à travers les coins. Je ne comprends pas quel élément cause le problème.WPF coins arrondis saignant à travers

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

Je suppose que quelque chose est évident que je aveuglante suis tout simplement pas voir. Voici le XAML que j'utilise:

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

Répondre

24

Je pense que c'est le Popup qui cause le problème. Essayez de définir AllowsTransparency sur True dans le menu contextuel.

Popup.AllowsTransparency

Réglé sur False, toutes les couleurs transparentes sont "fusionnés" avec le noir.

+0

qui l'a fait, merci! – Jason

0

Vous pouvez également placer la fenêtre contextuelle dans une bordure comportant des coins arrondis. Ceci est utile si vous ne pouvez pas modifier la propriété AllowsTransparency de la fenêtre contextuelle.

Quelque chose comme ceci:

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