下面的代码正在抛出一个NullReferenceException
. 我想保持按钮的背景相对于切换按钮的状态。
public partial class MainPage : PhoneApplicationPage
{
public static int key;
public MainPage()
{
ImageBrush brush= new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri(@"Images/Music on.png", UriKind.Relative));
if (key == 0)
music.Background = brush; //////NullReferenceException is throwing here
else
music.Background = null;
InitializeComponent();
}