Fade on Text Update
<Grid Grid.Row="1" Height="53" HorizontalAlignment="Left" Margin="12,70,0,0" Name="statusBackground" VerticalAlignment="Top" Width="1152" Background="#FF0080D4">
<TextBlock Name="questionText" Text="{Binding Path=StatusText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnTargetUpdated=True}" TextWrapping="WrapWithOverflow" FontFamily="Open Sans" FontSize="14" Padding="0" Foreground="White" Margin="20,6,23,6">
<TextBlock.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="statusBackground"
Storyboard.TargetProperty="(Grid.Opacity)"
From="1.0" To="0.0" Duration="0:0:0.3"/>
<DoubleAnimation
Storyboard.TargetName="statusBackground"
Storyboard.TargetProperty="(Grid.Opacity)"
From="0.0" To="1.0" Duration="0:0:0.7"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
</Grid>
class StatusChanged : INotifyPropertyChanged
{
private string _temp;
public string StatusText
{
get { return _temp; }
set
{
_temp = value;
NotifyPropertyChanged("StatusText");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
//Place this wherever the text is updated.
DataContext = new StatusChanged { StatusText = message };