Duration.TimeSpan Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Assembly: System.Windows (in System.Windows.dll)
| Exception | Condition |
|---|---|
| InvalidOperationException |
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.