|
1 | | -# TimeSpanEdit samples |
| 1 | +# WPF TimeSpanEdit Demo: Editing and Formatting Time Spans |
| 2 | +This sample shows how to let users view and edit TimeSpan values in a WPF app using the Syncfusion TimeSpanEdit. It covers keyboard and mouse interactions, step-based increments, field navigation, display formatting, watermark/null handling, read-only mode, and min/max limits so users can input durations precisely and intuitively. |
2 | 3 |
|
3 | | -This repository contains the samples that demonstrate the functionalities of TimeSpanEdit. |
| 4 | +## Features |
| 5 | +- Field navigation with Left/Right keys or mouse, with automatic advance after validation |
| 6 | +- Step-based increments via Up/Down keys, buttons, and mouse wheel (StepInterval) |
| 7 | +- Optional drag-to-increment (click and drag) for quick adjustments |
| 8 | +- Show/hide Up/Down arrow buttons |
| 9 | +- Keyboard-friendly editing with Up/Down arrows |
| 10 | +- Null handling and watermark text (AllowNull, NullString) |
| 11 | +- Custom display formatting for days/hours/minutes/seconds/milliseconds (Format: d, h, m, s, z) |
| 12 | +- Value changed notifications (ValueChanged with OldValue/NewValue) |
| 13 | +- Read-only display with programmatic updates (IsReadOnly) |
| 14 | +- Restrict selection within min/max bounds (MinValue/MaxValue) |
4 | 15 |
|
5 | | -<table> |
6 | | - <tr> |
7 | | - <td><a href="Samples/Getting-Started">Getting Started</a></td> |
8 | | - <td><a href="Samples/TimeSpanEdit-Features">Changing timespan value</a></td> |
9 | | - <td><a href="Samples/TimeSpanEdit-Features">Null Value Support</a></td> |
10 | | - <td><a href="Samples/TimeSpanEdit-Features">Time display formatting</a></td> |
11 | | - </tr> |
12 | | - <tr> |
13 | | - <td><a href="Samples/TimeSpanEdit-Features">Restrict user input</a></td> |
14 | | - <td><a href="Samples/TimeSpanEdit-Features">Restrict selection limit and validation</a></td> |
15 | | - <td><a href="Samples/Appearance">Appearance</a></td> |
16 | | - <td><a href="Samples/Themes">Themes</a></td> |
17 | | - </tr> |
18 | | -</table> |
| 16 | +## Getting Started |
| 17 | +1. Open the WPF solutions in the repository, for example: |
| 18 | + - Samples/Getting-Started/Getting-Started.sln |
| 19 | + - Samples/Appearance/Appearance.sln |
| 20 | + - Samples/Themes/Themes.sln |
| 21 | +2. Ensure .NET Framework 4.6.2 is targeted (see App.config and the .csproj files). |
| 22 | +3. Install or restore the required NuGet packages referenced in the projects: |
| 23 | + - Syncfusion.Shared.WPF |
| 24 | + - Syncfusion.Licensing |
| 25 | + - Optional theme packages under Samples/Themes/packages.config |
| 26 | +4. Add the Syncfusion XML namespace in XAML where you use the editor: |
| 27 | + - xmlns:syncfusion="http://schemas.syncfusion.com/wpf" |
| 28 | +5. Add TimeSpanEdit to your Window/Page and set core properties: |
| 29 | + - Value for the current TimeSpan |
| 30 | + - StepInterval for increment/decrement intervals |
| 31 | + - Format to control visible fields (e.g., d.h:m:s or h:m:s:z) |
| 32 | + - MinValue/MaxValue to constrain input |
| 33 | + - AllowNull and NullString for watermark behavior |
| 34 | + - ShowArrowButtons, IncrementOnScrolling, EnableExtendedScrolling, IsReadOnly as needed |
| 35 | + |
| 36 | +## Usage Tips |
| 37 | +- Field navigation: Move with Left/Right or click a field; focus advances automatically after validation. |
| 38 | +- Step interval: Use StepInterval to define how each field changes via keys, buttons, or mouse wheel. Example: with Value=1.1:1:10 and StepInterval=1.01:01:01, seconds change by 10s, minutes by 1m, hours by 1h, days by 1d. |
| 39 | +- Up/Down buttons: Toggle with ShowArrowButtons. |
| 40 | +- Mouse wheel: Enable/disable with IncrementOnScrolling. |
| 41 | +- Click-and-drag: Set EnableExtendedScrolling=True to drag up/down when unfocused. |
| 42 | +- Keyboard: Use Up/Down arrows to adjust the active field. |
| 43 | +- Null/watermark: Set AllowNull=True and Value=null; provide NullString for a hint. |
| 44 | +- Formatting: Control visible parts with Format tokens: |
| 45 | + - d (days), h (hours), m (minutes), s (seconds), z (milliseconds). |
| 46 | +- Value change notifications: Handle ValueChanged to track OldValue/NewValue. |
| 47 | +- Read-only: Use IsReadOnly=True to prevent user edits while allowing programmatic changes. |
| 48 | +- Limits: Use MinValue/MaxValue to keep values within bounds. |
| 49 | + |
| 50 | +## Samples in this repository |
| 51 | +- Getting started: Samples/Getting-Started |
| 52 | +- Feature demos (value changes, null support, formatting, input restriction, limits): Samples/TimeSpanEdit-Features |
| 53 | +- Appearance customization: Samples/Appearance |
| 54 | +- Themes using Syncfusion theme packages: Samples/Themes |
| 55 | + |
| 56 | +## About the Demo |
| 57 | +These samples focus on flexible duration input: precise field control, consistent step behavior, accessible keyboard/mouse editing, and clear formatting. Use them as a foundation to add validation, commands, or theming that fits your application’s UX and branding. |
0 commit comments