Ich entwickle eine Windows Phone App.Ich habe ein Bild. Dies ist sein XAML-Code:Wie kann ich image.source mit C# ändern?
<Image x:Name="imageclock" Grid.Row="1"
Source="Image/Myimage.png" Height="240" Width="240"
/>
Und ich image.source ändern möge mit diesem Code:
private void ClickonBtn(object sender, EventArgs e)
{
BitmapImage bm = new BitmapImage(new Uri("Image/Darktheme.png", UriKind.RelativeOrAbsolute));
imageclock.Source = bm;
}
Aber wenn ich erfüllen, imageclock.Source = Null, und das ist Fehler:
An exception of type 'System.NullReferenceException' occurred in Newappver1.DLL but was not handled in user code
Und Sie überprüft, dass im 'Image' Verzeichnis eine Datei' Darktheme.png' benannt ist? –