Search code examples
c#wpflabelblend

C# WPF preview in IDE is different than while debugging


I have a Label in a Grid and inside defined the fontsize, however, I have a global style defined for all labels in a dictionary. In the preview in Blend it looks fine and the fontsize is 10 and fontweight is normal but when I debug the program the fontsize is 17 and fontweight is medium. Even if I try to change fontsize and fontweight while the application is running no chnage is visible. Why is that happening and how can i avoid it?

edit: Even is I remove the setters from the dictionary there is no change so it can't be the problem. Also i added a app.manifest with DPI Awareness set to true and nothing changed.

Label: <Label Content="0" FontWeight="Normal" FontSize="10"/>

Dictionary:

<Style x:Key="{x:Type Label}" TargetType="{x:Type Label}">
                   <Setter Property="Foreground" Value="#C7C7C7"/>
                   <Setter Property="FontSize" Value="17"/>
                   <Setter Property="FontWeight" Value="Medium"/>
              </Style>

Preview:
Preview

Debug:
Debug


Solution

  • (I know, it's strange to answer your own question, but I fianlly found it!) Global styles for textblocks also affect labels. I wasn't aware of it, so I didn't added information about it. Anyway, thanks for help.