views:

184

answers:

1

hi, i'm trying to draw a rectangle with semi-circles at either end. i'm also trying to split the rectangle where the left half is a different colour to that of the right half. i've managed to do this using a stack panel and CombinedGeometry, as in the example below. however, the code below draws a line inbetween each control within the stack panel. i've tried several things to remove it or to draw over it. does anyone know how to remove this line, which i suspect is the border, or have a better approach? i have tried to add just the controls and not controls within borders, but it didn't make a difference. thanks

<UserControl x:Class="xxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
<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>

A: 

Set SnapsToDevicePixels to true on your StackPanel:

<StackPanel SnapsToDevicePixels="True" ...>

Read this MSDN article for an explanation.

HTH, Kent

Kent Boogaart
thank you, that worked :-)
Colin Rouse