Did you know - In Silverlight stretch doesn't work if you have width/height set explicitly

by rahul 6/28/2010 6:01:00 PM

In a Silverlight application, drag a border control, and inside the border drop a rectangle. Somewhat like the image below. The question here is… Horizontal Alignment setting has a default value Stretch. How come it is behaving as if it is Center?

image

<Rectangle Height="71" Name="rectangle2" Stroke="Black" StrokeThickness="1" Width="101" />

In the code above, you can see I haven't specified Horizontal Alignment. Hence, it should be Stretch! But it doesn't appear to be so. As a matter of fact, if you explicitly set Width/Height property (typically happens if you drag and drop control), Stretch loses its significance. Hence, you should delete the width attribute in case you are looking for Stretch in HorizontalAlignment.

image

<Rectangle Height="71" Name="rectangle2" Stroke="Black" StrokeThickness="1" />

Read more about it here.

Hope this helps,
Rahul


Quote of the day:
When you are eight years old, nothing is any of your business. - Lenny Bruce


blog comments powered by Disqus

Rahul Soni

Rahul Soni  Twitter

 LinkedIn

 Facebook

 Email me



Vivek Kumbhar

Vivek Kumbhar  Twitter

 LinkedIn

 Facebook

 Email me


Stack Exchange

profile for Vivek at Server Fault, Q&A for system administrators and IT professionals

profile for Rahul Soni at Stack Overflow, Q&A for professional and enthusiast programmers

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

All Items
Sign in

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2012, Rahul Soni

Powered by BlogEngine.NET 1.4.5.0