Domanda

Sto effettuando la mia prima incursione in WPF: ho un modulo semplice con un popup definito per l'aiuto in linea. Sto usando gli angoli arrotondati e per qualche motivo uno sfondo nero sta sanguinando attraverso gli angoli. Non capisco quale elemento sta causando il problema.

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

Suppongo sia qualcosa di palesemente ovvio che non vedo. Ecco la XAML che sto usando:

<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>
È stato utile?

Soluzione

Penso che sia il popup a causare il problema. Prova a impostare AllowsTransparency su True nel popup.

Popup.AllowsTransparency

Se impostato su False, tutti i colori trasparenti vengono "uniti" " con il nero.

Altri suggerimenti

Puoi anche avvolgere il popup in un bordo con angoli arrotondati. Ciò è utile se non è possibile modificare AllowsTransparency del popup.

Qualcosa del genere:

<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>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top