0

In my WPF app, I see these smear-like visual corruptions, especially around rounded corners. Notice the problem with the upper corners of the button.

visual corruption in upper corners

I tried the following but the issue persists:

  • SnapToDevicePixels=true
  • Resized and moved the app window.
  • Changed the screen resolution

What might be causing this?

XAML for the button:

<Button Width="Auto" Click="btnAdd_Click" Height="Auto" x:Name="btnAdd"  VerticalAlignment="Center" HorizontalAlignment="Right" Focusable="False" Margin="20,0,0,0" SnapsToDevicePixels="True">
            <StackPanel Orientation="Horizontal" Margin="0">
                <TextBlock Text="Ekle" HorizontalAlignment="Center" VerticalAlignment="Center"  Margin="0,0,5,0"/>
                <Image Source="/FideKiosk;component/Icons/right.png" MaxWidth="30" Width="15" Height="15"/>
            </StackPanel>
        </Button>

and then I have an implicit style in Application.Resources:

<Style TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Grid x:Name="grid">
                        <Rectangle RadiusX="10" RadiusY="10" x:Name="rectangle" Opacity="0.995">
                            <Rectangle.Effect>
                                <DropShadowEffect ShadowDepth="0" BlurRadius="0" Color="#FFC0F3AD" Opacity="0"/>
                            </Rectangle.Effect>
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.501,0.039" StartPoint="0.501,0.971">
                                    <GradientStop Color="#FF346223" Offset="0.124" />
                                    <GradientStop Color="#FF325625" Offset="0.526" />
                                    <GradientStop Color="#FF39622B" Offset="0.534" />
                                    <GradientStop Color="#FF367021" Offset="0" />
                                    <GradientStop Color="#FF4A8535" Offset="0.986" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True" Margin="15" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Opacity" TargetName="grid" Value="0.5"/>
                        </Trigger>
                        <Trigger Property="IsMouseCaptureWithin" Value="True">
                            <Setter Property="Effect" TargetName="rectangle">
                                <Setter.Value>
                                    <DropShadowEffect BlurRadius="30" Color="#FFC0F3AD" Opacity="1" ShadowDepth="0"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Fill" TargetName="rectangle">
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0.501,0.039" StartPoint="0.501,0.971">
                                        <GradientStop Color="#FF346223" Offset="0.303"/>
                                        <GradientStop Color="#FF325625" Offset="0.526"/>
                                        <GradientStop Color="#FF39622B" Offset="0.534"/>
                                        <GradientStop Color="#FF4A8535" Offset="0"/>
                                        <GradientStop Color="#FF8AC077" Offset="0.986"/>
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
Eren Ersönmez
  • 38,383
  • 7
  • 71
  • 92

1 Answers1

1

I used your code and could not find any artifacts in neither the designer nor when running the app. So unless you have more UI elements that are not in code you presented my guess is that the graphics card (hardware/driver) on your machine is causing this.

You could test this by switching to software rendering: Can I force WPF rendering tier?

Community
  • 1
  • 1
Emond
  • 50,210
  • 11
  • 84
  • 115
  • Thanks. If I disable the hw acceleration by setting HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration = 1, the issue goes away. So now what's the procedure? :) update the graphics driver, and if that doesnt work, get a new card? :) – Eren Ersönmez Feb 06 '12 at 11:54