Skip to content

Instantly share code, notes, and snippets.

@SteffenBlake
Last active April 15, 2017 07:23
Show Gist options
  • Save SteffenBlake/b994802cc3f710d63c1aaa7855ceb156 to your computer and use it in GitHub Desktop.
Save SteffenBlake/b994802cc3f710d63c1aaa7855ceb156 to your computer and use it in GitHub Desktop.
//'Block' is a Textblock in my form
//All of this method works perfectly fine
private void AddLine(string text)
{
if (Block.Inlines.Any())
Block.Inlines.FirstInline.Foreground = Brushes.Black;
var line = new Run(text+"\n") {Foreground = Brushes.Black};
Block.Inlines.Add(line);
Scrollbar.ScrollToBottom();
var fadeIn = new DoubleAnimation(0.0, 1.0, new Duration(TimeSpan.FromSeconds(3))) {AutoReverse = false};
Storyboard.SetTarget(fadeIn, line);
Storyboard.SetTargetProperty(fadeIn, new PropertyPath("Foreground.Opacity"));
var board = new Storyboard();
board.Children.Add(fadeIn);
board.Begin();
}
//This method animates successfuly, but the event function is not successfuly fixing opacity.
private void Wipe()
{
var fadeOut = new DoubleAnimation(1.0, 0.0, new Duration(TimeSpan.FromSeconds(3))) { AutoReverse = false };
Storyboard.SetTarget(fadeOut, Block);
Storyboard.SetTargetProperty(fadeOut, new PropertyPath(OpacityProperty));
var board = new Storyboard();
board.Children.Add(fadeOut);
board.Completed += (obj, events) =>
{
Block.Inlines.Clear();
Block.Opacity = 1.0; //Set a breakpoint here and it did indeed get hit, but it got set right back to 0 anyways?
};
board.Begin();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment