WPFTimelineControl 1.1.0

dotnet add package WPFTimelineControl --version 1.1.0
                    
NuGet\Install-Package WPFTimelineControl -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WPFTimelineControl" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WPFTimelineControl" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="WPFTimelineControl" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WPFTimelineControl --version 1.1.0
                    
#r "nuget: WPFTimelineControl, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=WPFTimelineControl&version=1.1.0
                    
Install WPFTimelineControl as a Cake Addin
#tool nuget:?package=WPFTimelineControl&version=1.1.0
                    
Install WPFTimelineControl as a Cake Tool

WPF Timeline Control

CodeFactor Build and Test NuGet

A timeline control for WPF, available for personal or commercial use under the MIT license.

alternate text is missing from this package README image

Using the control

  1. Install the NuGet package or download the source add add it to your Solution.

  2. In your Window or UserControl, add the XAML namespace:

     xmlns:tim="clr-namespace:WpfTimelineControl;assembly=WpfTimelineControl"
    
  3. Add the Timeline control:

    <Grid>
        <tim:Timeline x:Name="myTimeline" />
    </Grid>
    
  4. Through a Data Binding or code-behind, set the Timeline's DataContext:

    List<TimelineEntry> entries = new List<TimelineEntry>
    {
        new TimelineBar("Event 1", DateTime.Now, TimeSpan.FromSeconds(92), 0),
        new TimelinePoint("Event 2", DateTime.Now, TimeSpan.FromSeconds(17), 1),
    };
    
    var timelineBuilder = TimelineBuilderFactory.Create();
    
    var viewModel = timelineBuilder.BuildViewModel(entries.ToArray());
    
    myTimeline.DataContext = viewModel;
    

Customisation

See the Demo Apps for a demonstration of all the customisation options.

Dependency Properties

  • To customise the colours of the timeline entries, set TimelineEntryBrushes:

    <tim:Timeline TimelineEntryBrushes="{StaticResource TimelineItemColors}" />
    
    <Application.Resources>
        <SolidColorBrush x:Key="CorporateColor" Color="#2397D3" />
        <x:Array Type="SolidColorBrush" x:Key="TimelineItemColors">
            <SolidColorBrush Color="{Binding Color,Source={StaticResource CorporateColor1}}" />
            <SolidColorBrush Color="#E9C43B" />
        </x:Array>
    </Application.Resources>
    

    Type: Brush[] Default: { Brushes.Red, Brushes.Green, Brushes.Blue, Brushes.Yellow, Brushes.Magenta }

  • To change the colour used for the 'Labels exceed bars' setting, set LabelsExceedBarsSettingColorIndex:

    <tim:Timeline LabelsExceedBarsSettingColorIndex="2" />
    

    Type: int Default: 0

  • To choose whether the events' name labels are coloured, set ColoredEntryNameLabels:

    <tim:Timeline ColoredEntryNameLabels="True" />
    

    Type: Boolean Default: True

  • The 3 strings used in the control can be translated using NameLabel, StartLabel and EndLabel

    <tim:Timeline NameLabel="{lex:Loc Key=LBL_Name}"
                  StartLabel="{lex:Loc Key=LBL_Start}"
                  EndLabel="{lex:Loc Key=LBL_End}" />
    

    Type: string Default: "Name", "Start", "End"

  • With the top bar hidden, you can fix the LabelsExceedBars setting:

    <tim:Timeline LabelsExceedBars="False" />
    

    Type: Boolean Default: True

ViewModel Properties

  • Add a title to the timeline by setting Title:

    viewModel.Title = "Events Today"
    

    Type: string Default: NULL

  • Hide the settings controls on the top bar by setting ShowControls:

    viewModel.ShowControls = false
    

    Type: Boolean Default: true

  • Hide the longer date interval markers by setting ShowDateMarkers:

    viewModel.ShowDateMarkers = false
    

    Type: Boolean Default: true

  • With the top bar hidden, you can fix the PixelsPerInterval setting, which affects the width of each interval and therefore of the timeline control:

    viewModel.PixelsPerInterval = 160;
    

    Type: int Default: 320

  • With the top bar hidden, you can fix the MajorIntervalSeconds setting, which sets the timescale represented by each interval:

    viewModel.MajorIntervalSeconds = TimelineConstants.IntervalOptions[3];
    

    Type: int Default: [calculated based on the events]

Static Variables

The TimelineConstants class contains two static variables that control the behaviour of the timeline control.

The TimelineBuilder uses these values, which I have set based on my experience using this control at my previous company, but you may need to tweak them based on your data.

The timeline is always linear; each interval represents the same amount of time. The builder chooses one of the values from the IntervalOptions array, from 10 seconds up to 60 minutes.

The builder calculates the total duration of the events (from the beggining of the first to the end of the last) then divides this by the TimelineScalingFactor and finds the closest value from the options array.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.2

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 127 8/5/2024
1.0.0 91 7/24/2024