csharp 淡出文本更新

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 淡出文本更新相关的知识,希望对你有一定的参考价值。

<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 };

以上是关于csharp 淡出文本更新的主要内容,如果未能解决你的问题,请参考以下文章

csharp CrossFadeAlpha图片淡出[Unity C#]

如何在 Pygame 中淡入和淡出文本

SwiftUI - 使用淡入淡出动画更改文本

动画文本阴影淡入和淡出

在 React 中更改时淡出/在文本中

HTML5 画布中文本的淡出效果