怎样实现按钮点击后变图片
本来是一个按钮给他放上了图片,点击这个按钮后按钮的图片就变成宁一张,请问怎么实现
<Button Height="20" Width="20" HorizontalAlignment="Center">
<Button.Content>
<Image Source="/A4IM.Controls;component/FileManager/Images/Start.png" Stretch="UniformToFill" ></Image>
</Button.Content>
</Button>
[解决办法]
在Button的Click事件中重新设置图片即可
<Button Height="20" Width="20" HorizontalAlignment="Center" x:Name="Button1" OnClick="Button1_Click"> <Button.Content> <Image Source="/A4IM.Controls;component/FileManager/Images/Start.png" Stretch="UniformToFill" ></Image> </Button.Content> </Button>public void Button1_Click(object sender,EventArges e){ ((sender as Button).Content as Image).Source = new Uri("FileManager/Images/End.png",UriKind.Relative);}
[解决办法]