Page 1 of 1

Polygon Drawing Problem

Posted: 19 Sep 2016, 23:48
by kemarofangs
Is the polygon class supported? I've tried using it but nothing seems to get drawn. I've even tried a solidcolorbrush but nothing seems to work. Is there a decoration or alternative you can suggest to make this work?

Using V1.2.6.f5

This works...
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             x:Class="Darren.Asteroid"
             Width="100" Height="100">
  <UserControl.Background>
    <ImageBrush ImageSource="../../Raster/Texture/Asteroid.png" />
  </UserControl.Background>
</UserControl>
Yet this wont
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             x:Class="Darren.Asteroid"
             Width="100" Height="100">
  <Polygon>
        <Polygon.Fill>
          <!-- File path is relative to this file. -->
          <ImageBrush ImageSource="../../Raster/Texture/Asteroid.png" />
        </Polygon.Fill>
        <Polygon.Points>
            <PointCollection>
                <Point X="20" Y="0" />
                <Point X="70" Y="5" />
                <Point X="100" Y="20" />
                <Point X="80" Y="90" />
                <Point X="30" Y="95" />
                <Point X="0" Y="50" />
            </PointCollection>
        </Polygon.Points>
    </Polygon>
</UserControl>

Re: Polygon Drawing Problem

Posted: 20 Sep 2016, 03:05
by jsantos
For now, only Path and StreamGeometry in its Data property is supported. This is the most efficient way to draw shapes (even on WPF) and is valid for 99% of the cases.

Converting anything to a Path is trivial in Microsoft Blend, just go to the contextual menu of the Figure, Path -> Convert to Path.

For example, for your polygon this would be the equivalent:
<Path Data="M20,0 L70,5 L100,20 L80,90 L30,95 L0,50 z" Fill="Red" Stretch="Fill"/>

Re: Polygon Drawing Problem

Posted: 20 Sep 2016, 20:22
by kemarofangs
Thank you! It works perfectly.

Re: Polygon Drawing Problem

Posted: 20 Sep 2016, 20:53
by jsantos
You are welcome : )