Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:34:11+00:00 2026-06-04T04:34:11+00:00

I have the following TextBlock which will be a moving countdown timer: <TextBlock x:Name=countdown>

  • 0

I have the following TextBlock which will be a moving countdown timer:

 <TextBlock x:Name="countdown">
      <TextBlock.RenderTransform>
          <TranslateTransform x:Name="countdownTransform" />
      </TextBlock.RenderTransform>
 </TextBlock>

The following triggers should move the TextBlock and set the countdown text:

<Grid.Triggers>
    <EventTrigger SourceName="PlayButton" RoutedEvent="Button.Click">
         <BeginStoryboard>
               <Storyboard>
                    <DoubleAnimation Storyboard.TargetName="songProgressBar" 
                                     Storyboard.TargetProperty="Value"
                                     From="0:30:0" To="0" Duration="0:30:0" />
                    <DoubleAnimation Storyboard.TargetName="countdownTransform" 
                                     Storyboard.TargetProperty="X" AutoReverse="True" 
                                     From="0.0" To="{Binding ElementName=countdown, Path=Width}" Duration="0:30:0" />
               </Storyboard>
          </BeginStoryboard>
    </EventTrigger>
</Grid.Triggers>

However, the DoubleAnimation’s From property doesn’t accept (obviously) TimeSpan and for the second trigger, To property isn’t binding to the TextBlock’s Width. Is there a custom type of animation that accepts TimeSpan at To property?

I want to be able to do this in XAML, I know this is possible in c# code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:34:11+00:00Added an answer on June 4, 2026 at 4:34 am

    The Width of the TextBlock is NaN unless you explicitly set it, and NaN is not a valid value for the To property of a DoubleAnimation. You should have seen the error message in VS output window:

    System.Windows.Data Error: 5 : Value produced by BindingExpression is
    not valid for target property.; Value=’NaN’
    BindingExpression:Path=Width; DataItem=’TextBlock’ (Name=’countdown’);
    target element is ‘DoubleAnimation’ (HashCode=62632450); target
    property is ‘To’ (type ‘Nullable`1’)

    You could instead bind to ActualWidth:

    <DoubleAnimation ... To="{Binding ElementName=countdown, Path=ActualWidth}" />
    

    For the other animation: If the duration is a constant value, why not simply set From="30"? Otherwise you would also have to have a ProgressBar that takes a TimeSpan for Value, Minimum, Maximum etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following DataTemplate : <DataTemplate x:Key=ColoringLabels> <TextBlock Padding=0 Margin=0 Name=Username Text={Binding Username}
I have defined following in a ResourceDictionary: <DockPanel x:Key=errorDisplay LastChildFill=False> <Border Background=Red DockPanel.Dock=Top> <TextBlock
I have an ItemsControl with the following ItemTemplate: <DataTemplate x:Key=myItemTemplate> <TextBlock Height=??? Text={Binding Path=Description}
I have created a listbox control with following DataTemplate <DataTemplate x:Key=lb_Itemtemplate> <DockPanel> <TextBlock Text={Binding}
I have following requirement, I have C#/.Net console application, which refers to 'System.Data.Sqlite.dll' 'System.Data.Sqlite.dll'
I have the following XAML: <StackPanel> <StackPanel Orientation=Horizontal> <Border Name=B1 Width=Auto> <DataGrid /> </Border>
I have a combo box with the following DataTemplate: <DataTemplate x:Key=ComboBoxDataTemplate> <StackPanel> <TextBlock Text={Binding
I have following XAML (simplified, no ending tags): <Window Name=myWindow DataContext={Binding ElementName=myWindow} > <DockPanel>
I have a Pivot control which I am using as following within the XAML.
I have the following code which supposed to display a TreeView (the original code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.