How to change the font size of all(n number of ) texblocks inside the stack panel programmatically?
You can apply a style in markup:
<StackPanel.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="20"/>
</Style>
</StackPanel.Resources>
Yes, You can refer the code snippet below, where 'foobar' refers to your Stackpanel's Name.
foreach (var children in foobar.Children)
{
(children as TextBlock).FontSize = 20;
}
If you want all Subelements another Style why not use "ContentControl"?
For example like this:
<GroupBox Header="Some Header" FontSize="18" FontWeight="Bold">
<ContentControl FontSize="14" FontWeight="Normal">
....
</ContentControl
<GroupBox>
All elements inside the ContentControl Block will be st with normal weight and a size of 14.