I'm getting quite weird behavior with ClearType whenever I use AeroGlass in my WPF applications. I have found out that the following line sets my font rendering back to grey-scale:

mainWindowSrc.CompositionTarget.BackgroundColor = Colors.Transparent;

To get it back to work with AeroGlass I must set these .NET 4.0 properties to every control containing text:

RenderOptions.ClearTypeHint="Enabled" TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="ClearType"

Then it looks like this:

grey-scale on the left, cleartype on the right

Is there a way to achive the same effect without setting these properties to every control on the window?

Thanks.

有帮助吗?

解决方案

You could set this globally in the MainWindows constuctor.

Something like this:

RenderOptions.ClearTypeHintProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata { DefaultValue = ClearTypeHint.Enabled });
TextOptions.TextFormattingModeProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata { DefaultValue = TextFormattingMode.Display });
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top