Skip to main content

Microsoft Silverlight

Answered Question setting the height of the Layout.Children dynamicallyRSS Feed

(0)

ramya.mt
ramya.mt

Member

Member

9 points

28 Posts

setting the height of the Layout.Children dynamically

Hi,

How can I set the height of the Layout.Children element dynamically?

Thanks

neal.gabriel
neal.gab...

Participant

Participant

789 points

161 Posts

Answered Question

Re: setting the height of the Layout.Children dynamically

Hi, 

Do you want to change the height of all the Children in the Grid, or for one child ?

If it is for one child, you can access with the name of the CHild

Say for eg:

<Grid x:Name = "LayoutRoot">

<TextBlock x:Name="txtTest"/>

You can a  set height of the TextBlock in code behind as follows:

txtText.Height = 12;

else if you have n children for grid access it thru a for each loop

eg:

foreach (UIElement oUIElement in LayoutRoot.Children)

{

if (oUIElement is Border)

{

if (((Border)oUIElement).Child is TextBlock)

{

oTextBlock = (
TextBlock)((Border)oUIElement).Child;

oTextBlock.FontWeight = FontWeights.Normal;

oTextBlock.Height= 10;

}

}

}

 

This is the case when there is a border inside the Grid;

Use this logic and change accordingly

Regards...

Neal Gabriel

ramya.mt
ramya.mt

Member

Member

9 points

28 Posts

Re: Re: setting the height of the Layout.Children dynamically

Thanks a lot!!!

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities