Duration.TimeSpan Property

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.

ExceptionCondition
InvalidOperationException

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 Silverlight, 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 Silverlight, you can access the TimeSpan property and then manipulate the various TimeSpan APIs, such as Parse, FromSeconds, etc.

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show: