【发布时间】:2009-05-21 15:37:56
【问题描述】:
我想设置一个应用程序范围的值,即 TextHeight(其他也是),但我似乎找不到参考。 IOW,将 Text Height 设置为各种样式的 StaticResource 等。
【问题讨论】:
我想设置一个应用程序范围的值,即 TextHeight(其他也是),但我似乎找不到参考。 IOW,将 Text Height 设置为各种样式的 StaticResource 等。
【问题讨论】:
读完这个问题后,我的大脑有点疼。让我回答,好像我真的明白你在问什么。
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="100"/>
</Style>
</Application.Resources>
</Application>
澄清:
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
StartupUri="Window1.xaml">
<Application.Resources>
<sys:Double x:Key="MyTextHeight">32</sys:Double>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="{StaticResource MyTextHeight}"/>
</Style>
</Application.Resources>
</Application>
注意第 4 行,然后是新的 Double(还要注意类型必须与参数的类型匹配——我最初尝试 sys:Int32 导致一些有趣的不相关异常)。
【讨论】: