Skip to main content

Microsoft Silverlight

Answered Question Shape inside a buttonRSS Feed

(0)

ikerfernandes
ikerfern...

Member

Member

22 points

28 Posts

Shape inside a button

 Hi

I want to draw a rectangle or any shape inside a button which covers the entire button area. I am not able to do this using mark up

 
 <Button x:Name="Btn1" Content="Button1">

 <Rectangle Width="50" Height="50" Fill="Blue" />
               
</Button>

thanks. 

Bill Reiss
Bill Reiss

Contributor

Contributor

4840 points

919 Posts

Silverlight MVP
Answered Question

Re: Shape inside a button

If you don't specify a width and height on the Rectangle, it will grow to fill the available space in the button.


Bill Reiss, Coauthor of Hello! Silverlight 3
My blog (rss feed)

davidezordan
davidezo...

Contributor

Contributor

5690 points

875 Posts

Silverlight MVP
Answered Question

Re: Shape inside a button

Hi,

try with this code:

<Button x:Name="Btn1" Width="50" Height="50">

<Button.Content>

<Grid>

<Rectangle Fill="Blue" />

<TextBlock Text="Button1" HorizontalAlignment="Center" VerticalAlignment="Center"/>

</Grid>

</Button.Content>

</Button>

Thanks, Davide

Silverlight MVP

Blog Twitter Silverlight Experts

roomygupta
roomygupta

Member

Member

82 points

62 Posts

Answered Question

Re: Shape inside a button

Helllo.. You can edit button and can create any shape.. you just right click on button and go to edit a template.

ROOMY GUPTA
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities