MediaElement.Position MediaElement.Position MediaElement.Position MediaElement.Position Property


Gets or sets the current position of progress through the media's playback time.

public : TimeSpan Position { get; set; }
TimeSpan Position();

void Position(TimeSpan position);
public TimeSpan Position { get; set; }
Public ReadWrite Property Position As TimeSpan

Property Value

TimeSpan TimeSpan

The amount of time since the beginning of the media. The default is a TimeSpan with value "0:0:0".


Set this property to set a specific start-play position within the media.

A TimeSpan is represented as different types depending on the programming language you are using.

C# or Microsoft Visual Basic Use a System.TimeSpan structure. System.TimeSpan has utility members such as Parse(String) that make it easy to create, change or compare time values.

Visual C++ component extensions (C++/CX) Use a Windows::Foundation::TimeSpan structure. This structure has only one field member (Duration), which measures by 100-nanosecond units. If you intend to display a Position value in an hours:minutes:seconds format, you'll have to write your own logic for converting to that format from the Duration units.

If you are not sure of the current media source loaded as MediaElement.Source, always check CanSeek first. A streaming media source results in the MediaElement reporting CanSeek as false, and in this case you cannot use Position to set the playback point.

If Position is settable, then these value constraints apply:

  • If Position is set to a negative value, the value will revert to a TimeSpan with value "0:0:0".
  • If Position is set to a value larger than the media's NaturalDuration, then Position becomes the value of NaturalDuration.

Notes on XAML syntax

Setting a Position value in XAML is technically possible but not common. If you do set a Position in XAML, simulate the "FromString" type conversion behavior for a TimeSpan, in other words specify the value in the form "HH:MM:SS".

See also