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