Dynamically sized circle in pure XAML?


  • Hello,

    I'm fairly new to XAML and I want to check if I'm missing a simpler solution. If in Silverlight I want to have a circle dynamically stretch to fit its container while remaining a circle (instead of becoming an ellipse), is there a way to do this in pure XAML? I know how to do this in code-behind, by attaching an event handler that keeps the width in sync with the height, but I'm curious if there is a simpler way. The Ellipse and ArcSegment tags did not seem to be able to do this.



    Saturday, February 06, 2010 7:37 PM


All replies

  • You can set the Stretch to Uniform.

    <Ellipse Stretch="Uniform" Fill="Blue" />
    Saturday, February 06, 2010 9:31 PM
  • Thanks! That does it! Big Smile I had read that "Uniform" was the default value for the Stretch property for images, so I assumed it was also the default value for shapes, but it turns out that "Fill" is the default value for shapes. So I thought I had already tried that value when leaving out the Stretch property.

    Sunday, February 07, 2010 6:40 AM