WPF Image绑定一个枚举,希望在枚举值改变时显示不同图片。
<Image Name="img" Height="26" Margin="2" Source="1.png" DataContext="{Binding Path=.}"> <Image.Triggers> <DataTrigger Binding="{Binding Path=CurrentStatus}" Value="Connect"> <Setter Property="Source" TargetName="img" Value="2.png" /> </DataTrigger> </Image.Triggers> </Image>
public enum AvailableStatus { Connect, DisConnect, }