Thursday, May 5, 2022

[FIXED] How to set RenderOptions globally in C#?

Issue

i had problems with pixelated images and found later that RenderOptions.BitmapScalingMode="HighQuality" solves the problem. Is there a way to set this globally instead of adding the code to each individual image?


Solution

Simply set it from a globally applicable style:

<Application x:Class="SO_72015119.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <Style TargetType="{x:Type Image}" BasedOn="{StaticResource {x:Type Image}}">
            <Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" />
        </Style>
    </Application.Resources>
</Application>


Answered By - Orace
Answer Checked By - Robin (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.