kemarofangs
Topic Author
Posts: 32
Joined: 13 Jun 2014, 21:30

Polygon Drawing Problem

19 Sep 2016, 23:48

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>
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Polygon Drawing Problem

20 Sep 2016, 03:05

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"/>
 
kemarofangs
Topic Author
Posts: 32
Joined: 13 Jun 2014, 21:30

Re: Polygon Drawing Problem

20 Sep 2016, 20:22

Thank you! It works perfectly.
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Polygon Drawing Problem

20 Sep 2016, 20:53

You are welcome : )

Who is online

Users browsing this forum: No registered users and 0 guests