2011-08-10 4 views
3

버튼 누름에서 C# 코드를 사용하지 않고 일부 캔버스의 배경 이미지를 어떻게 변경합니까? 나는 배경색 변경하는 방법을 알고Windows Phone 7.1 - 버튼을 누를 때 배경 이미지를 변경하는 방법?

Canvas1.Background = new SolidColorBrush(Colors.Red); 

나는 온라인 자습서를 발견,하지만 VS는 형식 또는 네임 스페이스 이름 'BitmapImage는'을 (를) 찾을 수 없습니다 "라고 말한다 (당신은 using 지시문 또는 어셈블리 참조가 ?) "

var brush = new ImageBrush(); 
brush.ImageSource = new BitmapImage(new Uri(@"Images/myImage.png", UriKind.Relative)); 
Canvas1.Background = brush; 

무엇이 누락 되었습니까?

TIA!

답변

4

System.Windows.Media.Imaging 네임 스페이스에 대한 참조를 추가해야합니다. 이것을 클래스 상단에 추가하십시오. 다른 using directives이 있습니다.

using System.Windows.Media.Imaging; 
관련 문제