Pergunta

I have 3 PolyLines that have same geometry.

I would like to set offset to two of them, so they would appear right next to each other.

How can i do that?

thanx.

Foi útil?

Solução

That depends on the container you are using. If you use Grid (with no rows or colums) or canvas, they are directly on top of each other. You can space them apart by means of Margin (grid) or Left/Top (canvas).

Or use a different Panel, like Stackpanel, that arranges them next to each other automatically.

Edit: In the comments, we developed the idea of using a LinearGradientBrush to color a single Geometry, like this:

<Polyline StrokeThickness="20" Points="30,250 200,250">
    <Polyline.Stroke> 
        <LinearGradientBrush StartPoint="30,200" EndPoint="30,250" MappingMode="Absolute"> 
            <GradientStop Color="Red" Offset="1" /> 
            <GradientStop Color="Red" Offset="0.66" /> 
            <GradientStop Color="Yellow" Offset="0.66" /> 
            <GradientStop Color="Yellow" Offset="0.33" /> 
            <GradientStop Color="Green" Offset="0.33" /> 
            <GradientStop Color="Green" Offset="0" /> 
        </LinearGradientBrush> 
   </Polyline.Stroke> 

Outras dicas

I think I understood your exact need: you wish to draw polylines like on a road map, where multiple lines follow the same path but always keep the same distance between them.

This is a much more complicated problem. There is an excellent article by Key Johnson where he creates geometric visual brushes: Stacked Geometry Brush Factory.

An example of what he manages to do: alt text

You should explain in what container your polylines are set. In general I would use a RenderTransform.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top