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

SnapsToDevicePixelにsを設定trueしますStackPanel

<StackPanel SnapsToDevicePixels="True" ...>

説明については、このMSDNの記事をお読みください。

于 2009-10-17T16:41:48.190 に答える