【发布时间】:2014-10-24 10:42:27
【问题描述】:
假设,我有这样的东西(在 MainPage.xaml 中):
<Page.Resources>
<Style TargetType="TextBlock" x:Key="TextBlockStyle">
<Setter Property="FontFamily" Value="Segoe UI Light" />
<Setter Property="Background" Value="Navy" />
</Style>
</Page.Resources>
然后,我想将该 StaticResource 样式应用于我动态创建的 TextBlock(文件 MainPage.xaml.cs)。
有没有可能这样做而不是这样做:
myTextBlock.FontFamily = new FontFamily("Segoe UI Light");
myTextBlock.Background = new SolidColorBrush(Color.FromArgb(255,0,0,128));
【问题讨论】:
标签: c# xaml windows-phone-8 windows-phone-8.1