I am trying to implement a class for gif-like animation. The class derives from ContentView and I am using a System.Timers.Timer with this method assigned to Elapsed:
public void OnTimedEvent(Object sender, System.Timers.ElapsedEventArgs e){
++index;
Content = new Image () {
Source = filenames[index],
Aspect = Aspect.AspectFit
};
if (index >= filenames.Count - 1) {
_timer.Stop ();
}
}
filenames is List which stores all images I want to show.
But nothing happens on a android device, when the timer elapsed. The displayed content is still the old one. When I rotate the device suddenly all images are shown at the same time.
It seems like the following part from the assembly doesn't work?
public View Content {
get {
return this.content;
}
set {
if (this.content == value) {
return;
}
this.OnPropertyChanging ("Content");
if (this.content != null) {
base.InternalChildren.Remove (this.content);
}
this.content = value;
if (this.content != null) {
base.InternalChildren.Add (this.content);
}
this.OnPropertyChanged ("Content");
}
}
How do you change Content at runtime?