TimeSpan Property
Collapse the table of content
Expand the table of content

Duration.TimeSpan Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets the TimeSpan value that this Duration represents.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

public TimeSpan TimeSpan { get; }

Property Value

Type: System.TimeSpan
The TimeSpan value that this Duration represents.


The Duration does not represent a TimeSpan.

Getting this property raises an exception if the Duration does not represent a TimeSpan, for instance if the value is null, or if the value is Forever or Automatic. To avoid the exception, you should write your code such that TimeSpan is checked only after HasTimeSpan is verified as true.

In the JavaScript API for Windows Phone, only the Seconds property of a Duration is accessible, and the underlying time span value would have to be read in a seconds format. In the managed API for Windows Phone, you can access the TimeSpan property and then manipulate the various TimeSpan APIs, such as Parse, FromSeconds, etc.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

© 2017 Microsoft