İlk Windows 10 UWP uygulamasını geliştiriyorum. Benim bir resmim var. Bu onun XAML kodudur:Bir UWP uygulaması oluştururken image.source C# ile nasıl değiştirebilirim?
<Image x:Name="image"
HorizontalAlignment="Left"
Height="50"
Margin="280,0,0,25"
VerticalAlignment="Bottom"
Width="50"
Source="Assets/Five.png"/>
Ve bu kodla image.source değiştirmeye çalışıyorum im:
private void slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{
BitmapImage One = new BitmapImage(new Uri(@"Assets/One.png"));
BitmapImage Two = new BitmapImage(new Uri(@"Assets/Two.png"));
BitmapImage Three = new BitmapImage(new Uri(@"Assets/Three.png"));
BitmapImage Four = new BitmapImage(new Uri(@"Assets/Four.png"));
BitmapImage Five = new BitmapImage(new Uri(@"Assets/Five.png"));
if (slider.Value == 1)
{
image.Source = One;
}
else if (slider.Value == 2)
{
image.Source = Two;
}
else if (slider.Value == 3)
{
image.Source = Three;
}
else if (slider.Value == 4)
{
image.Source = Four;
}
else if (slider.Value == 5)
{
image.Source = Five;
}
}
Ama kodu derlemek zaman değişken bildiriminde işaret bu hatayı alıyorum:
UriFormatException kullanıcı kodu tarafından işlenmeyen
Merhaba, Yardımlarınız için teşekkürler. Ancak bu, ArgumentsException'ın kullanıcı kodu tarafından kullanılmamasına neden oldu. Herhangi bir fikir? Teşekkürler –
Bu benzer soruya bir göz atın: [http://stackoverflow.com/questions/32314799/uwp-image-uri-in-application-folder) – RobertoB
Merhaba, Gerçekten fazla kullanmadım. Yine de teşekkürler. –