Implementing Syncfusion WPF TimeSpanEdit
The TimeSpanEdit control allows users to set or display time as Days:Hours:Minutes:Seconds (d.h:m:s) format with support for keyboard and mouse interactions, custom formatting, and theming.
When to Use This Skill
Use the TimeSpanEdit control when you need to:
- Capture or display time durations/intervals in your WPF application
- Provide Days:Hours:Minutes:Seconds input with a user-friendly interface
- Enable users to increment/decrement time values using keyboard, mouse wheel, or buttons
- Display time with custom formats and labels (e.g., "5 days, 3 hours, 15 minutes, 30 sec")
- Apply min/max constraints to limit allowed time ranges
- Support null values with watermark text for empty states
- Style the control with colors, themes, and RTL support
Component Overview
Key Capabilities:
- ✓ Display time as Days:Hours:Minutes:Seconds (with milliseconds support)
- ✓ Programmatic and user-based value changes
- ✓ Keyboard navigation between fields (arrow keys)
- ✓ Mouse wheel and click-drag interactions
- ✓ Custom format strings with field labels
- ✓ Min/Max value constraints
- ✓ ValueChanged event notifications
- ✓ ReadOnly mode for display-only scenarios
- ✓ Null value support with watermarks
- ✓ Theme integration (SfSkinManager, ThemeStudio)
- ✓ RTL (Right-to-Left) flow direction support
Documentation Guide
| Topic |
File |
Focus |
| Setup |
getting-started.md |
Install NuGet, add via Designer/XAML/C# |
| Formats |
value-and-formats.md |
Custom format strings, labels, milliseconds |
| Interactions |
user-interactions.md |
Keyboard, mouse, buttons, drag, arrow keys |
| Constraints & Events |
constraints-and-events.md |
Min/Max, ValueChanged event, validation |
| Appearance |
appearance-and-theming.md |
Colors, themes, RTL, SfSkinManager |
Quick Start Example
XAML:
<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<Grid>
<!-- Basic TimeSpanEdit -->
<syncfusion:TimeSpanEdit
x:Name="timeSpanEdit"
Value="5.12:30:45"
Width="150"
Height="30" />
</Grid>
</Window>
C# Code-Behind:
using Syncfusion.Windows.Shared;
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
// Create and configure TimeSpanEdit
TimeSpanEdit editor = new TimeSpanEdit();
editor.Value = new TimeSpan(5, 12, 30, 45);
editor.Width = 150;
editor.Height = 30;
this.Content = editor;
}
}
Assembly Reference:
Add this to your WPF project:
Common Patterns
| Use Case |
XAML Setup |
| With Constraints |
MinValue="2.00:00:00" MaxValue="10.00:00:00" |
| Custom Format |
Format="d 'days' h 'hours' m 'minutes' s 'seconds'" |
| Precise Intervals |
StepInterval="1.00:15:30" IncrementOnScrolling="True" |
| Read-Only |
IsReadOnly="True" ShowArrowButtons="False" |
| Nullable |
AllowNull="True" NullString="Enter duration..." |
Quick Example:
<!-- Constrained input with custom format -->
<syncfusion:TimeSpanEdit
Value="5.08:30:00"
MinValue="2.00:00:00"
MaxValue="10.00:00:00"
Format="d 'days' h 'hours'" />
Key Props Reference
| Property |
Type |
Default |
Purpose |
Value |
TimeSpan? |
0.0:0:0 |
The time duration to display/edit |
Format |
string |
d.h:m:s |
Custom format string (d=days, h=hours, m=minutes, s=seconds, z=milliseconds) |
MinValue |
TimeSpan |
— |
Minimum allowed time duration |
MaxValue |
TimeSpan |
— |
Maximum allowed time duration |
StepInterval |
TimeSpan |
1.01:01:01 |
Increment/decrement interval for buttons/wheel/keyboard |
AllowNull |
bool |
false |
Allow null/empty values |
NullString |
string |
"" |
Watermark text when value is null |
ShowArrowButtons |
bool |
true |
Show up/down spinner buttons |
IncrementOnScrolling |
bool |
true |
Allow mouse wheel to change values |
EnableExtendedScrolling |
bool |
false |
Allow click & drag to change values |
IsReadOnly |
bool |
false |
Prevent user edits (read-only mode) |
Background |
Brush |
White |
Control background color |
Foreground |
Brush |
Black |
Text color |
SelectionBrush |
Brush |
RoyalBlue |
Selection highlight color |
FlowDirection |
FlowDirection |
LeftToRight |
RTL support (RightToLeft) |
Common Use Cases
| Scenario |
Key Settings |
| Duration Input |
Enable buttons, wheel, keyboard; set Min/Max; use labels |
| Display Only |
IsReadOnly="True" ShowArrowButtons="False"; use clear format |
| Precise Control |
Set StepInterval (e.g., 15-min); field-by-field keyboard entry |
| Flexible Entry |
All interactions enabled; logical step intervals; visual feedback |
Next Steps
- Start with Getting Started: Read getting-started.md to set up the control
- Format Your Display: Check value-and-formats.md for custom formats
- Enable Interactions: Review user-interactions.md for optimal UX
- Add Logic: Use constraints-and-events.md for events and limits
- Style It: Apply colors and themes with appearance-and-theming.md
1---2name: syncfusion-wpf-timespan-editor3description: How to implement the Syncfusion WPF TimeSpanEdit (TimeSpan Editor) control for time duration inputs. Use this skill when creating time duration inputs, capturing Days:Hours:Minutes:Seconds values, building time interval editors, or implementing time range controls with keyboard and mouse-based time entry. Includes setup, formatting, user interactions, constraints, and styling.4---56# Implementing Syncfusion WPF TimeSpanEdit78The [TimeSpanEdit](https://help.syncfusion.com/cr/wpf/Syncfusion.Windows.Shared.TimeSpanEdit.html) control allows users to set or display time as **Days:Hours:Minutes:Seconds** (d.h:m:s) format with support for keyboard and mouse interactions, custom formatting, and theming.910## When to Use This Skill1112Use the TimeSpanEdit control when you need to:13- Capture or display **time durations/intervals** in your WPF application14- Provide **Days:Hours:Minutes:Seconds** input with a user-friendly interface15- Enable users to **increment/decrement time values** using keyboard, mouse wheel, or buttons16- Display time with **custom formats** and labels (e.g., "5 days, 3 hours, 15 minutes, 30 sec")17- Apply **min/max constraints** to limit allowed time ranges18- Support **null values** with watermark text for empty states19- Style the control with **colors, themes, and RTL support**2021## Component Overview2223**Key Capabilities:**24- ✓ Display time as Days:Hours:Minutes:Seconds (with milliseconds support)25- ✓ Programmatic and user-based value changes26- ✓ Keyboard navigation between fields (arrow keys)27- ✓ Mouse wheel and click-drag interactions28- ✓ Custom format strings with field labels29- ✓ Min/Max value constraints30- ✓ ValueChanged event notifications31- ✓ ReadOnly mode for display-only scenarios32- ✓ Null value support with watermarks33- ✓ Theme integration (SfSkinManager, ThemeStudio)34- ✓ RTL (Right-to-Left) flow direction support3536---3738## Documentation Guide3940| Topic | File | Focus |41|-------|------|-------|42| **Setup** | [getting-started.md](references/getting-started.md) | Install NuGet, add via Designer/XAML/C# |43| **Formats** | [value-and-formats.md](references/value-and-formats.md) | Custom format strings, labels, milliseconds |44| **Interactions** | [user-interactions.md](references/user-interactions.md) | Keyboard, mouse, buttons, drag, arrow keys |45| **Constraints & Events** | [constraints-and-events.md](references/constraints-and-events.md) | Min/Max, ValueChanged event, validation |46| **Appearance** | [appearance-and-theming.md](references/appearance-and-theming.md) | Colors, themes, RTL, SfSkinManager |4748---4950## Quick Start Example5152**XAML:**53```xml54<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf">55 <Grid>56 <!-- Basic TimeSpanEdit -->57 <syncfusion:TimeSpanEdit 58 x:Name="timeSpanEdit"59 Value="5.12:30:45"60 Width="150"61 Height="30" />62 </Grid>63</Window>64```6566**C# Code-Behind:**67```csharp68using Syncfusion.Windows.Shared;6970public partial class MainWindow : Window {71 public MainWindow() {72 InitializeComponent();73 74 // Create and configure TimeSpanEdit75 TimeSpanEdit editor = new TimeSpanEdit();76 editor.Value = new TimeSpan(5, 12, 30, 45);77 editor.Width = 150;78 editor.Height = 30;79 80 this.Content = editor;81 }82}83```8485**Assembly Reference:**86Add this to your WPF project:87- `Syncfusion.Shared.WPF`8889---9091## Common Patterns9293| Use Case | XAML Setup |94|----------|-----------|95| **With Constraints** | `MinValue="2.00:00:00" MaxValue="10.00:00:00"` |96| **Custom Format** | `Format="d 'days' h 'hours' m 'minutes' s 'seconds'"` |97| **Precise Intervals** | `StepInterval="1.00:15:30" IncrementOnScrolling="True"` |98| **Read-Only** | `IsReadOnly="True" ShowArrowButtons="False"` |99| **Nullable** | `AllowNull="True" NullString="Enter duration..."` |100101**Quick Example:**102```xml103<!-- Constrained input with custom format -->104<syncfusion:TimeSpanEdit 105 Value="5.08:30:00"106 MinValue="2.00:00:00"107 MaxValue="10.00:00:00"108 Format="d 'days' h 'hours'" />109```110111---112113## Key Props Reference114115| Property | Type | Default | Purpose |116|----------|------|---------|---------|117| `Value` | `TimeSpan?` | `0.0:0:0` | The time duration to display/edit |118| `Format` | `string` | `d.h:m:s` | Custom format string (d=days, h=hours, m=minutes, s=seconds, z=milliseconds) |119| `MinValue` | `TimeSpan` | — | Minimum allowed time duration |120| `MaxValue` | `TimeSpan` | — | Maximum allowed time duration |121| `StepInterval` | `TimeSpan` | `1.01:01:01` | Increment/decrement interval for buttons/wheel/keyboard |122| `AllowNull` | `bool` | `false` | Allow null/empty values |123| `NullString` | `string` | `""` | Watermark text when value is null |124| `ShowArrowButtons` | `bool` | `true` | Show up/down spinner buttons |125| `IncrementOnScrolling` | `bool` | `true` | Allow mouse wheel to change values |126| `EnableExtendedScrolling` | `bool` | `false` | Allow click & drag to change values |127| `IsReadOnly` | `bool` | `false` | Prevent user edits (read-only mode) |128| `Background` | `Brush` | `White` | Control background color |129| `Foreground` | `Brush` | `Black` | Text color |130| `SelectionBrush` | `Brush` | `RoyalBlue` | Selection highlight color |131| `FlowDirection` | `FlowDirection` | `LeftToRight` | RTL support (RightToLeft) |132133---134135## Common Use Cases136137| Scenario | Key Settings |138|----------|--------------|139| **Duration Input** | Enable buttons, wheel, keyboard; set Min/Max; use labels |140| **Display Only** | `IsReadOnly="True"` `ShowArrowButtons="False"`; use clear format |141| **Precise Control** | Set `StepInterval` (e.g., 15-min); field-by-field keyboard entry |142| **Flexible Entry** | All interactions enabled; logical step intervals; visual feedback |143144---145146## Next Steps1471481. **Start with Getting Started**: Read [getting-started.md](references/getting-started.md) to set up the control1492. **Format Your Display**: Check [value-and-formats.md](references/value-and-formats.md) for custom formats1503. **Enable Interactions**: Review [user-interactions.md](references/user-interactions.md) for optimal UX1514. **Add Logic**: Use [constraints-and-events.md](references/constraints-and-events.md) for events and limits1525. **Style It**: Apply colors and themes with [appearance-and-theming.md](references/appearance-and-theming.md)