Why does Path and Polyline have different visualizations in WPF?

Why does path and polyline have different visualizations in WPF?

This happens both in the code and in the mix, maybe I missed something or is it just a smoothing effect.

<Window
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 x:Class="GeometryMonky.Window1"
 x:Name="Window"
 Title="Window1"
 Width="640" Height="480" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

 <Grid x:Name="LayoutRoot">
  <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF0000FF" Margin="100,10,0,0" Data="M289,39 L333,173" Width="1" HorizontalAlignment="Left" Height="100" StrokeThickness="1"/>

  <Polyline Stroke="#FF0000FF" Margin="115,178,417,168" StrokeThickness="1" Width="100" Height="100">
   <Polyline.Points>
    <Point>10,0</Point>
    <Point>10,100</Point>
   </Polyline.Points>
  </Polyline>
 </Grid>
</Window>

Sample image from Blend: http://img190.imageshack.us/img190/2965/wpfsmaple.png

Development System: WinXP SP2, VS 2008 + SP1

+3
source share
2 answers

This is due to the drawing modes of non-text objects. I tried to set the polyline object as described in the article below, and this makes it look like a path.

, - . :

, , .

public partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();
        // THIS IS THE LINE THATS IMPORTANT
        pLine.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
   }
}

xaml :

<Polyline x:Name="pLine" Stroke="#FF0000FF" Margin="115,178,417,168" StrokeThickness="1" Width="100" Height="100">
  <Polyline.Points>
    <Point>10,0</Point>
    <Point>10,100</Point>
   </Polyline.Points>
</Polyline>

Path. , , .

+3

Path Polyline xaml

RenderOptions.EdgeMode="Aliased"
+2

Source: https://habr.com/ru/post/1727502/


All Articles