0

我正在尝试在两端绘制一个带有半圆形的矩形。我还试图分割左半部分与右半部分颜色不同的矩形。我已经设法使用堆栈面板和 CombinedGeometry 来做到这一点,如下例所示。但是,下面的代码在堆栈面板中的每个控件之间画了一条线。我已经尝试了几件事来删除它或绘制它。有谁知道如何删除这条线,我怀疑这是边界,还是有更好的方法?我试图只添加控件而不是边界内的控件,但这并没有什么不同。谢谢

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

4

1 回答 1

1

SnapsToDevicePixels 设置为true您的StackPanel:

<StackPanel SnapsToDevicePixels="True" ...>

阅读这篇 MSDN 文章以获得解释。

于 2009-10-17T16:41:48.190 回答