WPF TextBlock text changed notify

后端 未结 2 985
迷失自我
迷失自我 2020-12-30 03:06

I have a screen contain about 15-20 TextBlocks each one bind to a different property, at first all the TextBlocks are empty the text update come from other client.

T

相关标签:
2条回答
  • 2020-12-30 03:33

    Already a bit old, but here the solution in pure xaml:

    <TextBlock VerticalAlignment="Center"
               Text="{Binding ErrorMsg, NotifyOnTargetUpdated=True}">
        <TextBlock.Triggers>
            <EventTrigger RoutedEvent="Binding.TargetUpdated">
                <BeginStoryboard>
                    <Storyboard>
                        <DoubleAnimation BeginTime="0:0:0"
                                         Duration="0:0:1"
                                         From="0.0"
                                         Storyboard.TargetProperty="Opacity"
                                         To="1.0" />
                    </Storyboard>
                </BeginStoryboard>
            </EventTrigger>
        </TextBlock.Triggers>
    </TextBlock>
    
    0 讨论(0)
  • 2020-12-30 03:36

    did you set the NotifyOnTargetUpdated property to true

    <TextBlock Text="{Binding Path=YourProperty, NotifyOnTargetUpdated=True}" TargetUpdated="OnTargetUpdated"/>
    
    0 讨论(0)
提交回复
热议问题