我想知道如何在代碼中而不是在xaml中動態地將圖片添加到按鈕。有人曾建議繼續通過以下方式如何在Silverlight中的WP7應用程序的代碼隱藏文件中設置背景圖片
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri(@"Images/myImage.png", UriKind.Relative));
AlphabetButton.Background = brush;
,但不是由智能感知,雖然我能找到BitConvertor和Bitmapcache檢測BitmapImage的。 如果不是這種方法,怎麼回事,我會設置背景圖片
謝謝.. :)我添加using.windows.media.imaging到命名空間。現在可以訪問BitmapImage。 – alfah