0

I am new to C# WPF and working on somebody else's code. (WPF version 3.0.6920.5011, as read from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0\Setup\Windows Presentation Foundation)

I already gave a look to various (quite old) Stackoverflow solutions, but they don't seem related to this problem: WPF Blurry fonts issue- Solutions, Text is blurred when transformed in WPF.

WPF: Why does text and elements blur if I use dropshadow effect on a parent item looks interesting, but there are no shadows applied to parents.

I observe this "blur" effect whenever an element is included in another one, and it is more and more visible as the inclusion goes deeper:

  • Device tab's text is perfectly readable
  • Global, Common and Inputs tabs' texts are lightly blurred
  • Pane inside Inputs is highly blurred.

blurred text

Alas I cannot provide XAML files because of company rules, but there are no settings about ClearType, applied shadows nor to blur effects.

Is there anything else I could check? Thank you in advance

Alex Poca
  • 2,406
  • 4
  • 25
  • 47
  • 1
    Have you tried something like [this](https://learn.microsoft.com/en-us/dotnet/api/system.windows.frameworkelement.uselayoutrounding). It seems like anti-aliasing problem. – mrogal.ski May 13 '19 at 10:00
  • @Mateusz, I applied the `UseLayoutRounding="True"` to the main Grid and various elements, but there are no improvements. Is there any way to set it as default property for the whole application? – Alex Poca May 13 '19 at 10:13
  • I know you said `there are no shadows applied to parents` – but looking at the image and given that the blurriness increases the lower you get in window hierarchy, please check this again. It almost looks like a transparent layer "above" the respective tab/subtab/panel. – LocEngineer May 13 '19 at 10:26
  • The fact it gets worse as you go deeper makes me think you might have a style automatically applied to each parent. – Andy May 13 '19 at 10:38
  • Solved! It was enough to add the property `UseLayoutRounding="True"` to the top-level element. please @Mateusz, change your comment to an answer so I can upvote it. Thank everybody – Alex Poca May 13 '19 at 11:36

1 Answers1

1

Add this to your top-level <Window> tag:

TextOptions.TextFormattingMode="Display"

This was first announced 10 years ago in a Microsoft post, it's amazing how to this day so few people use it.

Mark Feldman
  • 15,731
  • 3
  • 31
  • 58
  • Thank you. It is better than before, but it takes half a second to update the form with the non-blurred text. The initial form is blurred. – Alex Poca May 13 '19 at 11:25
  • 1
    If you also want it to not blur lines and other shapes, set `SnapsToDevicePixels="true"` also. – Bradley Uffner May 13 '19 at 12:15