This documentation is archived and is not being maintained.

DispatcherTimer.IsEnabled Property

Gets or sets a value that indicates whether the timer is running.

Namespace:  System.Windows.Threading
Assembly:  WindowsBase (in WindowsBase.dll)
XMLNS for XAML: Not mapped to an xmlns.

public bool IsEnabled { get; set; }
This property is not typically used in XAML.
<object IsEnabled="bool" .../>

Property Value

Type: System.Boolean
true if the timer is enabled; otherwise, false. The default is false.

IsEnabled must be set to true for the Tick event to be raised.

Calling Start sets IsEnabled to true.

Calling Stop sets IsEnabled to false.

The following example creates a DispatcherTimer. A new DispatcherTimer object named dispatcherTimer is created. The event handler dispatcherTimer_Tick is added to the Tick event. The Interval is set to 1 second using a TimeSpan object.

//  DispatcherTimer setup
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0,0,1);
dispatcherTimer.Start();

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: