¿Cómo dibujar una forma que cambia de tamaño con el formulario WPF?

I'm new to WPF and would like to know what to use to get a shape like the image below: enter image description here

I also wonder if it is possible that this design may follow the form's dimensions, ie, if the form is resized, the design is too.

De antemano, ¡gracias!

Windows 8.1, Visual Studio 2013, C#, WPF Application

preguntado el 22 de mayo de 14 a las 13:05

How are you using the image? are you looking for a custom window border or do you just want that drawn on -

How are you drawing the shape? Using geometry? -

I fail to understand why users continually come here to ask something that Google could (and has) answered many times previously: Resumen de formas y dibujo básico en WPF. Eso es realmente not what this website is for. Ask here when you have a real problem... otherwise ask Google. -

Sayse and Bob, my first question is just that, what to use to get to draw this shape? -

Sheridan, have a little patience, not all people are born with full knowledge, a simple question for you may be to me a "real" problem, anyway thank you too! -

2 Respuestas

To draw the shape you can use a Path. A path can draw any type of shape specified by its Data property. The Fill and Stroke defines the colors of the shape.

To "follow the form's dimensions" you can set the Stretch property to "Uniform". The shape will then scale accordingly to the window.

Aquí hay un ejemplo:

<Window x:Class="WpfApplication57.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="600" Width="800">
    <Grid>
      <Path Data="F1 M 0 0 800 0 800 30 200 30 150 60 0 60 0 0" 
            Fill="Yellow" 
            Stretch="Uniform" 
            Stroke="Black"
            StrokeThickness="4"
            VerticalAlignment="Top" />
   </Grid>
</Window>

Feliz codificación :-)

Best regards, Casper Korshøj

contestado el 22 de mayo de 14 a las 14:05

Casper, exactly what I need, what object to use and how to resize, perfect! Thanks and keep it up, helping those who are not born with knowledge! ;) - paulo balbino

Puedes utilizar una Path to get that shape and you can even use Blend to draw any shape, if you want just shapes.

   <Path Data="M200.125,197.375 L200.125,190.25 277.375,190.25 277.375,191.5 277.375,192.375 220,192.375 217.25,195.125 214.5625,197.8125 z" HorizontalAlignment="Left" Height="8.562" Margin="200.125,190.25,0,0" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="78.25" Fill="#FFF0F00C"/>

That should give you the Shape you wanted and in the comment mention above use that link

http://msdn.microsoft.com/en-us/library/ms747393%28v=vs.110%29.aspx

contestado el 22 de mayo de 14 a las 14:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.