Carlo
Carlo

Reputation: 25969

Keep an ellipse's height and width scaled

I just want to have a few ellipses that no matter how the container changes, the height and width should always be the same. I found a solution but it's too slow, I'll post it here to illustrate what I want to do. Let me know if you have any idea on a good way to achieve this.

<Grid>
    <Ellipse Width="Auto"
             Height="{Binding RelativeSource={RelativeSource Self}, Path=ActualWidth}"
             Stroke="Black"
             StrokeThickness="2" />
</Grid>

Thanks! =)

Upvotes: 4

Views: 4218

Answers (1)

Wallstreet Programmer
Wallstreet Programmer

Reputation: 9687

Set Stretch to Uniform: http://msdn.microsoft.com/en-us/library/system.windows.media.stretch.aspx

<Grid>
  <Ellipse Fill="Red" Stretch="Uniform"/>
</Grid>

Upvotes: 4

Related Questions