Pregunta

How can i resize Polygon which is placed in Canvas so it fills that canvas?

I don't want to change values of polygon points, I just want it to be displayed inside of canvas in case polygon coordinates are too large, too small or out of screen.

¿Fue útil?

Solución 2

Do you have the chance to replace the Canvas with a Grid? If so just set the Stretch attribute of the polygon, e.g. Uniform keeps the aspect ratio:

  <Grid Width="297" Height="159">
    <Polygon Points="10,110 110,110 110,10" Fill="Blue" Stretch="Uniform" />
  </Grid>

Otros consejos

Came across this problem recently and worked out a solid solution:

<Canvas x:Name="CanvasName">
    <Polygon Points="{Binding Path=PointCollectionName}" Stretch="Fill" Fill="Black"
        Width={Binding ElementName=CanvasName, Path=ActualWidth}"
        Height={Binding ElementName=CanvasName, Path=AcutalHeight}"/>
</Canvas> 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top