0

In my ResourceDictionary I'm setting default style for TextBlock:

<Style TargetType="TextBlock">
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}"/>
    <Setter Property="Margin" Value="10" />
</Style>

Then when I put lets say a CheckBox it looks fine in the designer but on runtime the TextBlock inside the CheckBox has that 10 margin.

What can cause that to happen?...

I'm setting the resources inside App.xaml.cs(Because I'm not using StartUri):

_mainView.Resources.Source = new Uri("pack://application:,,,/App;component/Resources/DarkTheme.xaml"); // Colors and brushes

ResourceDictionary style = new ResourceDictionary
{
    Source = new Uri("pack://application:,,,/App;component/Resources/Style.xaml")
};

_mainView.Resources.MergedDictionaries.Add(style); // Styles
Barak
  • 45
  • 7
  • It is a default Style that is applied to all TextBlocks in your application, also those created by other UI elements. See here: https://stackoverflow.com/q/9035878/1136211 – Clemens Jul 14 '19 at 10:20
  • @Clemens but in my case it's in reverse.. – Barak Jul 14 '19 at 13:57

0 Answers0