McTimeline is a reusable Uno/WinUI timeline control for rendering time-based items grouped by series.
It is implemented as a multi-targeted class library in src/McTimeline/McTimeline.csproj and currently targets:
net10.0net10.0-desktopnet10.0-windows10.0.26100net10.0-browserwasmnet10.0-androidnet10.0-ios
- Canvas-based timeline rendering with virtualized viewport math (
McTimelineViewport,McVirtualTimeAxis,McVirtualSeriesAxis) - Multi-series model with per-series style override (
McTimelineSeries.SeriesStyle) - Day and hour scale rendering with adaptive hour label density based on zoom
- Scroll and zoom interaction on pointer wheel:
Ctrl + Wheel: horizontal zoom (pixels-per-hour)Wheel: horizontal timeline scrollShift + Wheel: vertical series scroll- Anchor-preserving zoom around mouse position
- Legend panel (show/hide, configurable width, caption)
- Click events for both timeline items and legend series, including pointer button info
- Runtime style customization through dependency properties and resource dictionaries
- Custom timeline bar type support via
TimelineBarType(ITimelineBar+FrameworkElement) - Public refresh and fit APIs:
Refresh()ZoomSeriesToFit()
src/McTimeline/: reusable control librarysrc/McTimelineDemo/: Uno demo app with live configuration panel and style presetssrc/Timeline.Tests/: unit tests for viewport and axis logicsrc/CanvasTest/: additional rendering/viewport experiments
- Reference
src/McTimeline/McTimeline.csprojfrom your app. - Add the namespace in XAML:
xmlns:mctl="using:McTimeline". - Bind your data and range.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mctl="using:McTimeline">
<mctl:McTimeline
SeriesCollection="{x:Bind ViewModel.Series, Mode=OneWay}"
MinDate="{x:Bind ViewModel.DataInici, Mode=OneWay}"
MaxDate="{x:Bind ViewModel.DataFinal, Mode=OneWay}"
SeriesHeight="{x:Bind ViewModel.SeriesHeight, Mode=OneWay}"
ScaleHeight="{x:Bind ViewModel.ScaleHeight, Mode=OneWay}"
LegendWidth="{x:Bind ViewModel.LegendWidth, Mode=OneWay}"
PixelsPerHour="{x:Bind ViewModel.PixelsPerHour, Mode=TwoWay}" />
</Page>McTimelineSeriesCollection: collection of timeline seriesMcTimelineSeries:TitleItems(ObservableCollection<McTimelineItem>)SeriesStyle(optional per-series style)- helper methods:
Add,Remove,Clear,Sort,SortDescending McTimelineItem:IdKey,Title,DescriptionStart,EndVisible,Selected
ItemClicked(McTimelineItemClickedEventArgs)SeriesClicked(McTimelineSeriesClickedEventArgs)
Both event args include:
- clicked entity (
ItemorSeries) SeriesIndex- pointer button (
McTimelinePointerButton:Left,Right,Middle,X1,X2)
- data and range:
SeriesCollectionMinDate,MaxDate- layout and zoom:
PixelsPerHour(clamped to[10, 300])SeriesHeightScaleHeightLegendWidth- legend:
IsLegendVisibleLegendCaption- styling:
TimeScaleStyleTimeScaleDaysStyleTimeScaleTickStyleLegendStyleLegendCaptionStyleLegendItemStyleTimelineScrollStyleTimelineCanvasStyleTimelineItemStyleLegendItemTemplate- extensibility:
TimelineBarType
The control ships theme-aware resources in:
src/McTimeline/Themes/McTimelineResources.xamlsrc/McTimeline/Themes/ThemeResources.Light.xamlsrc/McTimeline/Themes/ThemeResources.Dark.xamlsrc/McTimeline/Themes/Generic.xaml
See src/McTimeline/README_STYLES.md for the full catalog and examples.
If you replace ControlTemplate, keep these named parts compatible:
PART_ContainerPART_TimeScaleGridPART_TimeScaleDaysPART_TimeScaleHoursPART_LegendBorderPART_SeriesRepeaterPART_TimelineScrollPART_TimelineCanvasPART_HScrollPART_VScrollPART_LegendCanvas
Current demo includes:
- configuration panel with live controls for:
- theme toggle
- add new series
- legend visibility
- legend width
- series height
- scale height
- pixels-per-hour (zoom)
- zoom-series-to-fit action
- style presets:
- multicolor series styles
- gradient series styles
- selected item and selected series feedback panels
- keyboard/mouse instruction helper for zoom/scroll behavior
- library style default is
McTimelineDefaultPixelsPerHour = 60 - demo forces startup zoom to
30on page load and keepsPixelsPerHourbound inTwoWay - zoom changes from
Ctrl + Wheelupdate the bound value and the configuration panel
Build library:
dotnet build C:\Code\McTimeline\src\McTimeline\McTimeline.csproj -c Debug -f net10.0-desktopBuild demo:
dotnet build C:\Code\McTimeline\src\McTimelineDemo\McTimelineDemo\McTimelineDemo.csproj -c Debug -f net10.0-desktopRun tests:
dotnet test C:\Code\McTimeline\src\Timeline.Tests\Timeline.Tests.csproj -c DebugCurrent automated tests cover:
- time-axis conversions, clamping, intersections, zoom-to-fit
- series-axis conversions, clamping, scrolling, intersections, zoom-to-fit
- viewport size/scroll synchronization and item positioning
- The project is under active development; implementation details can evolve.
- If you update public behavior (properties, interactions, defaults), update this README and
src/McTimeline/README_STYLES.mdtogether.
