Let's say I have something like this (in 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>
Then I would like to apply this StaticResource style to a dynamically created TextBlock (MainPage.xaml.cs file).
Is there any way to do this instead of doing something like this:
myTextBlock.FontFamily = new FontFamily("Segoe UI Light"); myTextBlock.Background = new SolidColorBrush(Color.FromArgb(255,0,0,128));
source share