我在MainWindow.xaml.cs
. 我想实现这样的效果,当业务逻辑运行时runbutton的背景图片切换到powerOnOff1.png
,当业务逻辑完成后背景图片切换回powerOnOff0.png
。
private void Run_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//set run button background image to powerOnOff1.png indicates business logic is going to run.
BitmapImage ima0 = new BitmapImage(new Uri("picture/powerOnOff1.png", UriKind.Relative));
image.Source = ima0;
//business logic
......
//restore Runbutton background image to powerOnOff0.png indicates business logic is finished.
BitmapImage ima1 = new BitmapImage(new Uri("picture/powerOnOff0.png", UriKind.Relative));
image.Source = ima1;
}
上面的代码不起作用。它总是显示powerOnOff0.png
背景图像。它需要多线程吗?