views:

83

answers:

1

If I have a ChildWindow in Silverlight I can apply the FontSizeProperty and it is inherited by child items.

<controls:ChildWindow FontSize="14">

     <StackPanel>
          <TextBlock Content="Hello">
          <TextBlock Content="World">
     </StackPanel>

</controls:ChildWindow>

Now that's fine if you want the whole page to have the same font size, but I want to do something like this and have inheritance in smaller blocks:

<controls:ChildWindow>

     <StackPanel FontSize="14">
          <TextBlock Content="Hello">
          <TextBlock Content="World">
     </StackPanel>

     <StackPanel FontSize="10">
          <TextBlock Content="Hello">
          <TextBlock Content="World">
     </StackPanel>

</controls:ChildWindow>

This doesn't compile. Is there any way i can achieve this pattern in Silverlight without having to define a style for StackPanel (I think that would work).

Are there any other containers that let me set FontSize for its descendants - or can I write one that would?

I want to easily set fontsize to be larger for certain StackPanels. I don't want to resort to styles because its very specialized and I won't need to reuse the style elsewhere.

Whats the best way to do this?

+2  A: 

You can wrap each StackPanel in a ContentControl, which does implement FontSize.

Ben M
thanks! i got close with ContentPresenter, but this is what I was needing
Simon_Weaver