2009-10-17 6 views
0

J'essaie de dessiner un rectangle avec des demi-cercles à chaque extrémité. J'essaie aussi de diviser le rectangle où la moitié gauche est une couleur différente de celle de la moitié droite. J'ai réussi à le faire en utilisant un panneau de pile et CombinedGeometry, comme dans l'exemple ci-dessous. cependant, le code ci-dessous trace une ligne entre chaque contrôle dans le panneau de pile. J'ai essayé plusieurs choses pour l'enlever ou le dessiner. est-ce que quelqu'un sait comment enlever cette ligne, que je suspecte est la frontière, ou avoir une meilleure approche? J'ai essayé d'ajouter seulement les contrôles et non les contrôles à l'intérieur des frontières, mais cela n'a pas fait de différence. grâceStackPanel dessine des artefacts entre chaque contrôle enfant

<UserControl x:Class="xxx" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
<StackPanel Orientation="Horizontal" DataContext="{Binding ElementName=InfoControl, Path=.}"> 
    <Border Background="White" BorderThickness="0"> 
     <Path Fill="LightBlue"> 
      <Path.Data> 
       <CombinedGeometry GeometryCombineMode="Intersect"> 
        <CombinedGeometry.Geometry1> 
         <EllipseGeometry Center="15,15" RadiusX="15" RadiusY="15"/> 
        </CombinedGeometry.Geometry1> 
        <CombinedGeometry.Geometry2> 
         <RectangleGeometry Rect="0 0 15 30"/> 
        </CombinedGeometry.Geometry2> 
       </CombinedGeometry> 
      </Path.Data> 
     </Path> 
    </Border> 
    <Border Background="LightBlue" BorderThickness="0"> 
     <TextBlock x:Name="nameTextBlock" Foreground="SteelBlue" VerticalAlignment="Center" FontSize="16" Margin="0 0 5 0">-</TextBlock> 
    </Border> 
    <Border Background="CornflowerBlue" BorderThickness="0"> 
     <TextBlock x:Name="dataTextBlock" Foreground="White" VerticalAlignment="Center" FontSize="16" Margin="5 0 0 0">-</TextBlock> 
    </Border> 
    <Border Background="White" BorderThickness="0"> 
     <Path Fill="CornflowerBlue"> 
      <Path.Data> 
       <CombinedGeometry GeometryCombineMode="Intersect"> 
        <CombinedGeometry.Geometry1> 
         <EllipseGeometry Center="0,15" RadiusX="15" RadiusY="15"/> 
        </CombinedGeometry.Geometry1> 
        <CombinedGeometry.Geometry2> 
         <RectangleGeometry Rect="0 0 30 30"/> 
        </CombinedGeometry.Geometry2> 
       </CombinedGeometry> 
      </Path.Data> 
     </Path> 
    </Border> 
</StackPanel> 

Répondre

1

Set SnapsToDevicePixel s à true sur votre StackPanel:

<StackPanel SnapsToDevicePixels="True" ...> 

Lire this MSDN article pour une explication.

+0

merci, ça a marché :-) –

Questions connexes