Disable anti-aliasing in WPF

Situation

You’re creating some kind of control that needs to be sharply visible.

Problem

WPF uses anti-aliasing on default so the control is rendered “soft”.

Solution

Deactivate anti-aliasing for the whole WPF application, the control or the specific part that needs to be sharp by setting the EdgeModeProperty to aliased.

Sample

/// <summary>
/// Interaction logic for LogicControl.xaml
/// </summary>
public partial class LogicControl : UserControl
{
  /// <summary>
  /// Creates a new instance.
  /// </summary>
  public LogicControl()
  {
    InitializeComponent();
    this.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
  }
}

Sources

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.