WPF按钮图标被镜像的,为什么呢? [英] WPF Button icon gets mirrored, why?

查看:280
本文介绍了WPF按钮图标被镜像的,为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此按钮定义图像时按以下步骤进行看起来不错(见截图)。请注意,以字母'T'的盾形图标正确显示。

This Button looks fine (see screenshot) when defining the image as done below. Note that the shield shaped icon with the letter 'T' is visualized correctly.

<Button Command="w:MainWindow.BrowseTorrentSite">
    <StackPanel>
        <Image Source="../icons/kickasstorrent.png" />
    </StackPanel>
</Button>

当我想依靠启用状态的按钮,图标被镜像。

When I want to rely on the buttons enabled state, the icon gets mirrored.

<StackPanel 
      Orientation="Horizontal" 
      FlowDirection="RightToLeft">
        <Button 
            x:Name="KatButton" 
            Command="w:MainWindow.BrowseTorrentSite">
            <StackPanel>
                <Image>
                    <Image.Style>
                        <Style TargetType="Image">
                            <Style.Triggers>
                                <DataTrigger
                                    Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" 
                                    Value="True">

                                    <Setter Property="Source" Value="../icons/kickasstorrent.png" />
                                </DataTrigger>
                                <DataTrigger 
                                    Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" 
                                    Value="False">

                                    <Setter Property="Source" Value="../icons/kickasstorrent_disabled.png" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>
            </StackPanel>
        </Button>
</StackPanel>

请注意,用字母T现在镜像盾牌形状的图标。

什么是负责镜像图标?

如果有人有技巧的任何方式可以调试这一点,随意点我在正确的方向!

If somebody has tips to debug this in whatever way possible, feel free to point me in the right direction!

推荐答案

问题是父StackPanel中。如果的StackPanel 是定义的的FlowDirection 从右到左,在图片定义继承这个属性导致的翻转图标。

The problem is in the parent StackPanel. If the StackPanel is defining the FlowDirection from right to left, the Image definition inherits this property which results in the flipped icon.

要解决图像本身对这个问题重新定义左到右。

To solve this problem redefine left to right on the image itself.

    <StackPanel 
        Orientation="Horizontal" 
        FlowDirection="RightToLeft">
        <Button>
            <Image FlowDirection="LeftToRight">
                <Image.Style>
                    <!-- etc etc -->
                </Image.Style>
            </Image>
       </Button>
    </StackPanel>

这篇关于WPF按钮图标被镜像的,为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆