Skip to content

Instantly share code, notes, and snippets.

@dkudelko
Created March 4, 2016 11:02
Show Gist options
  • Save dkudelko/e9c34535be438dc16547 to your computer and use it in GitHub Desktop.
Save dkudelko/e9c34535be438dc16547 to your computer and use it in GitHub Desktop.
image tirgger fade
public class FadeTriggerAction : TriggerAction<VisualElement>
{
public FadeTriggerAction() {}
public int StartsFrom { set; get; }
protected override void Invoke (VisualElement visual)
{
visual.Animate("", new Animation( (d)=>{
var val = StartsFrom == 0 ? d : 1-d;
visual.Opacity = val;
}),
length:1000, // milliseconds
easing: Easing.Linear);
}
}
Image image = new Image ();
image.Triggers.Add(new Trigger(typeof(Image)) {
Property = Image.SourceProperty,
EnterActions = {
new FadeTriggerAction() {
StartsFrom = 1
}
},
ExitActions = {
new FadeTriggerAction() {
StartsFrom = 0
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment