Live Chat Icon For mobile
Live Chat Icon

How can I set the text as ‘Completed’ in a progress bar at the end of progress?

Platform: WPF| Category: ProgressBar

This can be done using the code given below.

[XAML]

        <Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' >
            <!-- For demonstration purposes, animate ProgressBar.Value -->
            <Page.Triggers>
                <EventTrigger RoutedEvent=’Page.Loaded’>
                    <BeginStoryboard>
                        <Storyboard TargetName=’ProgressBar’ TargetProperty=’Value’>
                            <DoubleAnimation From=’0’ To=’100’ Duration=’0:0:1’ />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Page.Triggers>
            <Grid Height='30' >
                <ProgressBar Name=’ProgressBar’ />
                <Viewbox>
                    <TextBlock>
        <TextBlock.Style>
          <Style TargetType=’TextBlock’>
            <!-- Make the text 'Loading ...' by default-->
            <Setter Property=’Text’ Value=’Loading ...’ />          
            <!-- But when ProgressBar.Value is 100, change the text to 'Complete' -->
            <Style.Triggers>
              <DataTrigger Binding=’{Binding Value, ElementName=ProgressBar}’ Value=’100’>
                <Setter Property=’Text’ Value=’Complete’ />
              </DataTrigger>
            </Style.Triggers>
          </Style>
        </TextBlock.Style>
      </TextBlock>
                </Viewbox>
            </Grid>
        </Page>

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.