Levin
Levin

Reputation: 77

Background image in WPF button is displayed horizontaly flipped (like a mirror)

When i set a background image for a WPF button - it appears as the opposite direction - horizontal flipped (like a mirror). Any solution? (It does not have to do with the flowdirection)

 <Button x:Name="btnGoodMark" Grid.Row="1" Content="{Binding Path=GoodBtnTxt}" Click="btnGoodMark_Click" FontSize="30">
                <Button.Background>
                    <ImageBrush ImageSource ="Images/Green_V.png"  ></ImageBrush>
                </Button.Background>
            </Button>

Upvotes: 1

Views: 564

Answers (2)

rmojab63
rmojab63

Reputation: 3631

(Edited) Use ScaleTransform:

        <Button x:Name="btnGoodMark" RenderTransformOrigin="0.5,0" Width="100" Height="100" Grid.Row="1" Content="ABC" FontSize="30" >
        <Button.RenderTransform>
            <ScaleTransform ScaleX="-1" ></ScaleTransform>
        </Button.RenderTransform>
    </Button>

Upvotes: 0

Clemens
Clemens

Reputation: 128061

From your question it isn't clear why there should be any horizontal flipping of the image at all.

However, set the ImageBrush's RelativeTransform property to revert that effect:

<Button.Background>
    <ImageBrush ImageSource="Images/Green_V.png">
        <ImageBrush.RelativeTransform>
            <ScaleTransform ScaleX="-1" CenterX="0.5"/>
        </ImageBrush.RelativeTransform>
    </ImageBrush>
</Button.Background>

Upvotes: 1

Related Questions