RoguePlanetoid
RoguePlanetoid

Reputation: 4576

How to Centre Silverlight Elements relative to each other?

I have an Ellipse and a TextBlock that I want to be Centred relative to each other - ie the TextBlock shows in the Centre of the Ellipse no matter the content eg. its says 88 (like a Bingo Ball) and the Ellipse is the Ball itself - and the number shows in the centre of this ball.

How to I accomplish this in Silverlight, where the sizes are not fixed, as if possible I want the Ellipse and TextBlock to be the relative size of their parent - which I cannot seem to do in Silverlight either.

Related to this problem is I cannot find the code behind equivelent for "LimeGreen" the colour, which can be set in XAML but not in Code, where only a few Colours are available the in the Color class?

Upvotes: 1

Views: 326

Answers (1)

AnthonyWJones
AnthonyWJones

Reputation: 189485

The style of layout desired is provided by the Grid control. However I suspect you would also want the text to scale with the size of the ellipse, this can be acheived with the Silverlight Toolkit Viewbox control:-

<Grid>
    <Ellipse Fill="Blue" />
    <controlstk:Viewbox>
        <TextBlock Text="88" Margin="2" />  
    </controlstk:Viewbox>       
</Grid>

BTW, LimeGreen is #FF32CD32.

Upvotes: 1

Related Questions