RSS

How to set control Height Width Auto in silverlight

15 Feb

You need to use your code like this:

MyComponent.Width = double.NaN;

suppose you have a rectangle as your object named rect

rect.SetValue(Rectangle.HeightProperty, Double.NaN);

suppose you have a grid as your object named mygrid

mygrid.SetValue(Grid.HeightProperty, Double.NaN);

 

your place this where you reset height or Initialize or page_load event like

  public  CallerInfo()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Page_Loaded);
}

 

void Page_Loaded(object sender, RoutedEventArgs e)
{
myGrid.SetValue(Grid.HeightProperty, Double.NaN);
rect.SetValue(Rectangle.HeightProperty, Double.NaN);

}

 

Warning!

rec.SetValue(Rectangle.HeightProperty,”Auto”); not worked

its giving me error “DependencyProperty of type System.Double cannot be set on an object of type System.String”.

Advertisements
 
1 Comment

Posted by on February 15, 2012 in Silverlight

 

Tags: ,

One response to “How to set control Height Width Auto in silverlight

  1. teto

    May 21, 2012 at 2:07 pm

    Thanks

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: