Friday, 19 September 2008

XAML: Diff between Rectangle and Border?

image

So here we are, a rectangle and a border with curved corners. Hmmm, what are the differences between them? Why different property names and API? Maybe I am too dumb to discover. Can someone please let me know?

7 comments:

  1. The difference is HUGE!

    I'm not sure if I'm going to tell you... Keep you guessing some more..?

    Well, the difference is....

    The Border is a Container Control, the Rectangle is a Path Geometry.

    So say you want a nice rounded rectangle around your content. One way to do is is to have a Rectangle at a lower z-index and then overlay your content on top of it.

    A better option is to have a border surround your element, and then just add what ever you want inside the Border control.

    :)

    ReplyDelete
  2. Oh I see! Didn't notice the Border is a container! (now you know how much coding I actually get chance to do normally...)

    So is it possible to have an irregular shaped element and add to a border control which will automatically draw around the irregular shape?

    ReplyDelete
  3. You can put anything inside a boarder, but it will always look like a rectangle.

    If you want a border around an irregular shape (a path), simply set the stroke thickness and stroke brush :)

    ReplyDelete
  4. that's true... By the way, can you do fancy colouring like gradient for stokes?

    ReplyDelete
  5. Stroke is just a Brush, so you can put anything in it (solid color, gradients, pictures, tiles, or even videos)

    :)

    ReplyDelete
  6. And if i need the geometry of the Border, can i get it? how?

    I need the geometry to check wether a border is intersecting a polygon in a canvas

    ReplyDelete