Windows Phone 앱을 개발 중입니다. 이미지가 있습니다. 이는 자사의 XAML 코드 :C#으로 image.source를 어떻게 바꿀 수 있습니까?
<Image x:Name="imageclock" Grid.Row="1"
Source="Image/Myimage.png" Height="240" Width="240"
/>
그리고 나는이 코드를 image.source을 변경하려면 :
private void ClickonBtn(object sender, EventArgs e)
{
BitmapImage bm = new BitmapImage(new Uri("Image/Darktheme.png", UriKind.RelativeOrAbsolute));
imageclock.Source = bm;
}
하지만 난 준수 할 때, imageclock.Source = 널이 오류입니다 :
An exception of type 'System.NullReferenceException' occurred in Newappver1.DLL but was not handled in user code
그리고 당신은'Darktheme.png'라는 이름의 파일이있는'Image' 디렉토리에있는 것을 확인? –