开发者

How does inheritance of FontSize in silverlight tree work?

开发者 https://www.devze.com 2022-12-16 03:47 出处:网络
If I have a ChildWindow in Silverlight I can apply the FontSizeProperty and it is inherited by child items.

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 reso开发者_JAVA百科rt to styles because its very specialized and I won't need to reuse the style elsewhere.

Whats the best way to do this?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号