Table of Contents

Class ActivityViewModel

Namespace
Tudormobile.Strava.UI.ViewModels
Assembly
Tudormobile.Strava.UI.dll

Represents a view model for an activity, providing access to activity details and allowing updates to certain properties.

public class ActivityViewModel : INotifyPropertyChanged
Inheritance
ActivityViewModel
Implements
Inherited Members

Remarks

This class serves as a bridge between the activity data model and the user interface, exposing activity details as read-only properties and allowing updates to specific fields such as the activity name, description, and type.

Constructors

ActivityViewModel()

Initializes a new instance of the ActivityViewModel class with a default DetailedActivity.

public ActivityViewModel()

ActivityViewModel(DetailedActivity)

Initializes a new instance of the ActivityViewModel class with the specified activity details.

public ActivityViewModel(DetailedActivity activity)

Parameters

activity DetailedActivity

The detailed activity data used to initialize the view model. Cannot be null.

Properties

Athlete

Athlete.

public AthleteId Athlete { get; }

Property Value

AthleteId

AverageSpeed

The activity's average speed, in meters per second

public double AverageSpeed { get; }

Property Value

double

Commute

Gets or sets a value indicating whether this activity is a commute.

public bool Commute { get; set; }

Property Value

bool

Description

Gets or sets a description of the activity.

public string Description { get; set; }

Property Value

string

Distance

The activity's distance, in meters

public double Distance { get; }

Property Value

double

DoneCommand

Gets or sets the command to be executed when the "Done" action is triggered.

public ICommand? DoneCommand { get; set; }

Property Value

ICommand

ElapsedTime

The activity's elapsed time, in seconds

public double ElapsedTime { get; }

Property Value

double

Id

The unique identifier of the activity

public long Id { get; }

Property Value

long

MaxSpeed

The activity's max speed, in meters per second

public double MaxSpeed { get; }

Property Value

double

MovingTime

The activity's moving time, in seconds

public double MovingTime { get; }

Property Value

double

Name

The name of the activity

public string Name { get; set; }

Property Value

string

SportType

Gets or sets the type of sport associated with the activity.

public SportTypes SportType { get; set; }

Property Value

SportTypes

StartDate

The time at which the activity was started.

public DateTime StartDate { get; }

Property Value

DateTime

TotalElevationGain

The activity's total elevation gain.

public double TotalElevationGain { get; }

Property Value

double

Trainer

Gets or sets a value indicating whether this activity was recorded on a training machine.

public bool Trainer { get; set; }

Property Value

bool

UpdateCommand

Gets or sets the command to update the activity.

public ICommand? UpdateCommand { get; set; }

Property Value

ICommand

Methods

OnPropertyChanged(string)

Raises the PropertyChanged event to notify listeners that a property value has changed.

protected virtual void OnPropertyChanged(string propertyName)

Parameters

propertyName string

The name of the property that changed. This value cannot be null or empty.

Remarks

This method is typically called by property setters to notify data-binding clients or other listeners of property changes. Subclasses can override this method to provide additional behavior when a property changes.

Events

PropertyChanged

Occurs when a property value changes.

public event PropertyChangedEventHandler? PropertyChanged

Event Type

PropertyChangedEventHandler

Remarks

This event is typically used to notify subscribers that a property value has been updated. It is commonly implemented in classes that support data binding or need to signal changes to property values.