Line with fill and stroke

人走茶凉 提交于 2019-12-12 21:13:21

问题


I'm trying to create a line that looks like this in wpf.

Does anyone have any idea how to do this? I need to bind the x and y coordinates, so a line works really well except I can't make it look like this.


回答1:


You can't do this with a simple line, but with a Border object it is very easy.

<Border Width="100" Height="10" Background="#FFFFDAAD" BorderBrush="Orange" BorderThickness="0,3"/>



回答2:


You can overlay multiple Lines, Polylines or Polygons to achieve similar effects and use resources to avoid duplication, for example (just inspiration):

<Canvas ClipToBounds="True" Height="200" Width="200">
    <Canvas.Resources>
        <PointCollection x:Key="Wings">0,-2 62,-2 62,22 58,22 58,2 0,2</PointCollection>
    </Canvas.Resources>
    <Polygon Points="{StaticResource Wings}" Fill="Black" Stroke="White" StrokeThickness="4"/>
    <Polygon Points="{StaticResource Wings}" StrokeThickness="8" Stroke="White"/>
    <Polygon Points="{StaticResource Wings}" StrokeThickness="4" Stroke="Red"/>
</Canvas>



回答3:


I have best solution, make for "outline" line StrokeThickness more than "simple" line:

      <Line x:Name="borderLine" X1="0" X2="400" Y1="0" Y2="0" StrokeThickness="1" Stroke="White"/>
      <Line x:Name="borderOutlineLine" X1="0" X2="400" Y1="0" Y2="0" StrokeThickness="0.3" Stroke="Black"/>


来源:https://stackoverflow.com/questions/9642395/line-with-fill-and-stroke

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!