Created
March 4, 2016 11:02
-
-
Save dkudelko/e9c34535be438dc16547 to your computer and use it in GitHub Desktop.
image tirgger fade
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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