Code: Select all
Image newComponent = (Image)component; // component is a VisualElement component
newComponent.Source = ImagesReferences.Instance.someImage[index];
< /code>
Aber ich habe ein Problem, es sieht so aus, als ob das Bild zuerst für eine sehr kurze Zeit verschwindet und dann das richtige Bild angezeigt wird. Es sieht seltsam aus und bei Animationen ist es schlimmer, Bilder flackern.public string value = "file.png";
Ich habe versucht, mein Bild in einem Imagesource so aufzurufen: Imagesource symage = mictionource.fromFile ("Datei.png"); Der Benutzer soll diesen spezifischen Fall für wie vor einem Jahr korrigieren, und es scheint wieder so, als ob es nicht funktioniert, weil ich hier bin. />
Code: Select all
private async Task AnimateImage(bool isAnimationUp, CancellationToken cancellationToken)
{
try
{
if (cancellationToken.IsCancellationRequested)
{
return;
}
ImageAnimatedCover.Source = ImagesReferences.Instance.animationCover[currentImageIndex];
await Task.Delay(80);
if (isAnimationUp && currentImageIndex < ImagesReferences.Instance.animationCover.Count - 1)
{
currentImageIndex++;
await AnimateImage(isAnimationUp, cancellationToken);
}
else if (currentImageIndex >= 1 && !isAnimationUp)
{
currentImageIndex--;
await AnimateImage(isAnimationUp, cancellationToken);
}
}
catch (OperationCanceledException)
{
Debug.WriteLine("Animation annulée");
}
}