Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF按钮图标被镜像,为什么?_Wpf_Xaml_Button_Icons - Fatal编程技术网

WPF按钮图标被镜像,为什么?

WPF按钮图标被镜像,为什么?,wpf,xaml,button,icons,Wpf,Xaml,Button,Icons,当按以下步骤定义图像时,此按钮看起来很好(请参见屏幕截图)。请注意,带字母“T”的盾形图标显示正确 <Button Command="w:MainWindow.BrowseTorrentSite"> <StackPanel> <Image Source="../icons/kickasstorrent.png" /> </StackPanel> </Button> 当我想依赖按钮启用状态时,图标会

当按以下步骤定义图像时,此按钮看起来很好(请参见屏幕截图)。请注意,带字母“T”的盾形图标显示正确

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

当我想依赖按钮启用状态时,图标会被镜像

<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”的盾形图标现在已镜像。

什么负责镜像图标


如果有人有技巧以任何可能的方式调试它,请随时为我指出正确的方向

问题出在父StackPanel中。如果
StackPanel
从右到左定义
流向
,则
图像
定义将继承此属性,从而产生翻转图标

要解决此问题,请在图像本身上从左到右重新定义

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